docs: update template_file examples

Use the new non-deprecated style.

refs #4025
This commit is contained in:
Paul Hinze 2015-11-24 08:59:57 -06:00
parent 047ac8e534
commit bd23ab35bf
1 changed files with 8 additions and 15 deletions

View File

@ -178,7 +178,7 @@ A template resource looks like:
```
resource "template_file" "example" {
filename = "template.txt"
template = "${hello} ${world}!"
vars {
hello = "goodnight"
world = "moon"
@ -190,17 +190,10 @@ output "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
@ -221,7 +214,7 @@ 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"
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)}"