website: document templates

While we're here, fix a broken link.
This commit is contained in:
Josh Bleecher Snyder 2015-05-04 11:41:18 -07:00
parent 76bcac3031
commit 2da7c9a823
2 changed files with 31 additions and 1 deletions

View File

@ -114,3 +114,33 @@ The supported built-in functions are:
back into a list. This is useful for pushing lists through module
outputs since they currently only support string values.
Example: `split(",", module.amod.server_ids)`
## Templates
Long strings can be managed using templates. Templates are [resources](/docs/configuration/resources.html) defined by a filename and some variables to use during interpolation. They have a computed `rendered` attribute containing the result.
A template resource looks like:
```
resource "template_file" "example" {
filename = "template.txt"
vars {
hello = "goodnight"
world = "moon"
}
}
output "rendered" {
value = "${template_file.example.rendered}"
}
```
Assuming `template.txt` looks like this:
```
${hello} ${world}!
```
Then the rendered value would be `goodnight moon!`.
You may use any of the built-in functions in your template.

View File

@ -9,7 +9,7 @@ description: |-
# Provider Configuration
Providers are responsible in Terraform for managing the lifecycle
of a [resource](/docs/configuration/resource.html): create,
of a [resource](/docs/configuration/resources.html): create,
read, update, delete.
Every resource in Terraform is mapped to a provider based