hashicorp / terraform-provider-template

Terraform template provider
https://www.terraform.io/docs/providers/template/
Mozilla Public License 2.0
131 stars 89 forks source link

template_dir resource should support wildcarding on the source_dir attribute #37

Open aggallim opened 6 years ago

aggallim commented 6 years ago

Hi I would like to see the template_dir resource support wildcarding on the source_dir attribute.

template_dir renders all files within the source_dir directory. I would like to be able to specif a wildcard in the source-dir. For my use case this is to target a particular file type.

Terraform Version

Terraform v0.11.1

Affected Resource(s)

template_dir

Actual Behavior

resource "template_dir" "this" {
  source_dir      = "../templates/"
  destination_dir = "${path.root}/rendered"

  vars {
    foo= "bar"
  }
}

Expected Behavior

resource "template_dir" "this" {
  source_dir      = "../templates/*.tpl"
  destination_dir = "${path.root}/rendered"

  vars {
    foo= "bar"
  }
}

I'd like to keep my code DRY and not use template_file unless someone can suggest a way to use count in template_file and enumerate the .tpl files.

tomlarkworthy commented 5 years ago

or adding excludes would be really helpful to me. The situation I am in is trying to deploy GAE manually via gcloud. You need the app.yaml and .js files in a directory. I want the env variables to be templated in app.yaml, however, I use the ${} syntax in the sibling javascript files. template_dir chokes coz it can't instanciate the Javascript templates. I don't want to escape them as it breakes JS IDE. I would like to copy the whole directory over but apply templating only to the app.yaml