Skip to content

Commit

Permalink
docs: update template_file examples
Browse files Browse the repository at this point in the history
Use the new non-deprecated style.

refs #4025
  • Loading branch information
phinze committed Nov 24, 2015
1 parent 047ac8e commit bd23ab3
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions website/source/docs/configuration/interpolation.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)}"
Expand Down

0 comments on commit bd23ab3

Please sign in to comment.