Skip to content

Commit bd23ab3

Browse files
committed
docs: update template_file examples
Use the new non-deprecated style. refs hashicorp#4025
1 parent 047ac8e commit bd23ab3

1 file changed

Lines changed: 8 additions & 15 deletions

File tree

website/source/docs/configuration/interpolation.html.md

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -178,29 +178,22 @@ A template resource looks like:
178178

179179
```
180180
resource "template_file" "example" {
181-
filename = "template.txt"
182-
vars {
183-
hello = "goodnight"
184-
world = "moon"
185-
}
181+
template = "${hello} ${world}!"
182+
vars {
183+
hello = "goodnight"
184+
world = "moon"
185+
}
186186
}
187187
188188
output "rendered" {
189-
value = "${template_file.example.rendered}"
189+
value = "${template_file.example.rendered}"
190190
}
191191
```
192192

193-
Assuming `template.txt` looks like this:
194-
195-
```
196-
${hello} ${world}!
197-
```
198-
199193
Then the rendered value would be `goodnight moon!`.
200194

201195
You may use any of the built-in functions in your template.
202196

203-
204197
### Using Templates with Count
205198

206199
Here is an example that combines the capabilities of templates with the interpolation
@@ -220,8 +213,8 @@ variable "hostnames" {
220213
221214
resource "template_file" "web_init" {
222215
// here we expand multiple template_files - the same number as we have instances
223-
count = "${var.count}"
224-
filename = "templates/web_init.tpl"
216+
count = "${var.count}"
217+
template = "${file("templates/web_init.tpl")}"
225218
vars {
226219
// that gives us access to use count.index to do the lookup
227220
hostname = "${lookup(var.hostnames, count.index)}"

0 commit comments

Comments
 (0)