website: document templates
While we're here, fix a broken link.
This commit is contained in:
parent
76bcac3031
commit
2da7c9a823
|
@ -114,3 +114,33 @@ The supported built-in functions are:
|
||||||
back into a list. This is useful for pushing lists through module
|
back into a list. This is useful for pushing lists through module
|
||||||
outputs since they currently only support string values.
|
outputs since they currently only support string values.
|
||||||
Example: `split(",", module.amod.server_ids)`
|
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.
|
||||||
|
|
|
@ -9,7 +9,7 @@ description: |-
|
||||||
# Provider Configuration
|
# Provider Configuration
|
||||||
|
|
||||||
Providers are responsible in Terraform for managing the lifecycle
|
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.
|
read, update, delete.
|
||||||
|
|
||||||
Every resource in Terraform is mapped to a provider based
|
Every resource in Terraform is mapped to a provider based
|
||||||
|
|
Loading…
Reference in New Issue