# Referencing the template_dir resource ensures that it will be
# created or updated before this aws_instance resource is provisioned.
source = "${template_dir.config.destination_dir}"
destination = "/etc/myapp"
}
}
variable "consul_addr" {}
variable "server_ami" {}
```
## Argument Reference
The following arguments are supported:
* `source_path` - (Required) Path to the directory where the files to template reside.
* `source_dir` - (Required) Path to the directory where the files to template reside.
* `destination_path` - (Required) Path to the directory where the templated files will be written.
* `destination_dir` - (Required) Path to the directory where the templated files will be written.
* `vars` - (Optional) Variables for interpolation within the template. Note
that variables must all be primitives. Direct references to lists or maps
will cause a validation error.
NOTE: Any required parent directories are created automatically. Additionally, any external modification to either the files in the source or destination directories will trigger the resource to be re-created.
Any required parent directories of `destination_dir` will be created
automatically, and any pre-existing file or directory at that location will
be deleted before template rendering begins.
After rendering this resource remembers the content of both the source and
destination directories in the Terraform state, and will plan to recreate the
output directory if any changes are detected during the plan phase.
Note that it is _not_ safe to use the `file` interpolation function to read
files create by this resource, since that function can be evaluated before the
destination directory has been created or updated. It *is* safe to use the
generated files with resources that directly take filenames as arguments,
as long as the path is constructed using the `destination_dir` attribute
to create a dependency relationship with the `template_dir` resource.
## Template Syntax
@ -44,7 +93,7 @@ but you only have access to the variables defined in the `vars` section.
To access interpolations that are normally available to Terraform
configuration (such as other variables, resource attributes, module
outputs, etc.) you'll have to expose them via `vars` as shown below:
outputs, etc.) you can expose them via `vars` as shown below: