Skip to content

Commit b49fbb5

Browse files
authored
Merge pull request #8566 from MiLk/docs/interpolation-template-data
Template are now data sources
2 parents 7be6310 + 95a86cc commit b49fbb5

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,12 @@ The supported built-in functions are:
246246

247247
## Templates
248248

249-
Long strings can be managed using templates. [Templates](/docs/providers/template/index.html) 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.
249+
Long strings can be managed using templates. [Templates](/docs/providers/template/index.html) are [data-sources](/docs/configuration/data-sources.html) defined by a filename and some variables to use during interpolation. They have a computed `rendered` attribute containing the result.
250250

251-
A template resource looks like:
251+
A template data source looks like:
252252

253253
```
254-
resource "template_file" "example" {
254+
data "template_file" "example" {
255255
template = "${hello} ${world}!"
256256
vars {
257257
hello = "goodnight"
@@ -260,7 +260,7 @@ resource "template_file" "example" {
260260
}
261261
262262
output "rendered" {
263-
value = "${template_file.example.rendered}"
263+
value = "${data.template_file.example.rendered}"
264264
}
265265
```
266266

@@ -271,7 +271,7 @@ You may use any of the built-in functions in your template.
271271
### Using Templates with Count
272272

273273
Here is an example that combines the capabilities of templates with the interpolation
274-
from `count` to give us a parametized template, unique to each resource instance:
274+
from `count` to give us a parameterized template, unique to each resource instance:
275275

276276
```
277277
variable "count" {
@@ -285,7 +285,7 @@ variable "hostnames" {
285285
}
286286
}
287287
288-
resource "template_file" "web_init" {
288+
data "template_file" "web_init" {
289289
// here we expand multiple template_files - the same number as we have instances
290290
count = "${var.count}"
291291
template = "${file("templates/web_init.tpl")}"
@@ -299,11 +299,11 @@ resource "aws_instance" "web" {
299299
// ...
300300
count = "${var.count}"
301301
// here we link each web instance to the proper template_file
302-
user_data = "${element(template_file.web_init.*.rendered, count.index)}"
302+
user_data = "${element(data.template_file.web_init.*.rendered, count.index)}"
303303
}
304304
```
305305

306-
With this, we will build a list of `template_file.web_init` resources which we can
306+
With this, we will build a list of `template_file.web_init` data sources which we can
307307
use in combination with our list of `aws_instance.web` resources.
308308

309309
## Math

0 commit comments

Comments
 (0)