github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/website/source/docs/providers/template/index.html.markdown (about) 1 --- 2 layout: "template" 3 page_title: "Provider: Template" 4 sidebar_current: "docs-template-index" 5 description: |- 6 The Template provider is used to template strings for other Terraform resources. 7 --- 8 9 # Template Provider 10 11 The template provider exposes data sources to use templates to generate 12 strings for other Terraform resources or outputs. 13 14 Use the navigation to the left to read about the available data sources. 15 16 ## Example Usage 17 18 ``` 19 # Template for initial configuration bash script 20 data "template_file" "init" { 21 template = "${file("init.tpl")}" 22 23 vars { 24 consul_address = "${aws_instance.consul.private_ip}" 25 } 26 } 27 28 # Create a web server 29 resource "aws_instance" "web" { 30 # ... 31 32 user_data = "${data.template_file.init.rendered}" 33 } 34 ``` 35 36 Or using an inline template: 37 38 ``` 39 # Template for initial configuration bash script 40 data "template_file" "init" { 41 template = "$${consul_address}:1234" 42 43 vars { 44 consul_address = "${aws_instance.consul.private_ip}" 45 } 46 } 47 48 # Create a web server 49 resource "aws_instance" "web" { 50 # ... 51 52 user_data = "${data.template_file.init.rendered}" 53 } 54 ``` 55 56 -> **Note:** Inline templates must escape their interpolations (as seen 57 by the double `$` above). Unescaped interpolations will be processed 58 _before_ the template.