docs: update template_file examples
Use the new non-deprecated style. refs #4025
This commit is contained in:
parent
047ac8e534
commit
bd23ab35bf
|
@ -178,29 +178,22 @@ A template resource looks like:
|
|||
|
||||
```
|
||||
resource "template_file" "example" {
|
||||
filename = "template.txt"
|
||||
vars {
|
||||
hello = "goodnight"
|
||||
world = "moon"
|
||||
}
|
||||
template = "${hello} ${world}!"
|
||||
vars {
|
||||
hello = "goodnight"
|
||||
world = "moon"
|
||||
}
|
||||
}
|
||||
|
||||
output "rendered" {
|
||||
value = "${template_file.example.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.
|
||||
|
||||
|
||||
### Using Templates with Count
|
||||
|
||||
Here is an example that combines the capabilities of templates with the interpolation
|
||||
|
@ -220,8 +213,8 @@ variable "hostnames" {
|
|||
|
||||
resource "template_file" "web_init" {
|
||||
// here we expand multiple template_files - the same number as we have instances
|
||||
count = "${var.count}"
|
||||
filename = "templates/web_init.tpl"
|
||||
count = "${var.count}"
|
||||
template = "${file("templates/web_init.tpl")}"
|
||||
vars {
|
||||
// that gives us access to use count.index to do the lookup
|
||||
hostname = "${lookup(var.hostnames, count.index)}"
|
||||
|
|
Loading…
Reference in New Issue