2015-05-08 03:20:05 +02:00
|
|
|
---
|
|
|
|
layout: "template"
|
|
|
|
page_title: "Provider: Template"
|
|
|
|
sidebar_current: "docs-template-index"
|
|
|
|
description: |-
|
|
|
|
The Template provider is used to template strings for other Terraform resources.
|
|
|
|
---
|
|
|
|
|
|
|
|
# Template Provider
|
|
|
|
|
2016-05-22 00:09:55 +02:00
|
|
|
The template provider exposes data sources to use templates to generate
|
2015-05-08 03:20:05 +02:00
|
|
|
strings for other Terraform resources or outputs.
|
|
|
|
|
2016-05-22 00:09:55 +02:00
|
|
|
Use the navigation to the left to read about the available data sources.
|
2015-05-08 03:20:05 +02:00
|
|
|
|
|
|
|
## Example Usage
|
|
|
|
|
|
|
|
```
|
|
|
|
# Template for initial configuration bash script
|
2016-05-22 00:09:55 +02:00
|
|
|
data "template_file" "init" {
|
2015-11-24 06:32:04 +01:00
|
|
|
template = "${file("init.tpl")}"
|
2015-05-08 03:20:05 +02:00
|
|
|
|
|
|
|
vars {
|
|
|
|
consul_address = "${aws_instance.consul.private_ip}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Create a web server
|
|
|
|
resource "aws_instance" "web" {
|
|
|
|
# ...
|
|
|
|
|
2016-05-22 00:09:55 +02:00
|
|
|
user_data = "${data.template_file.init.rendered}"
|
2015-05-08 03:20:05 +02:00
|
|
|
}
|
|
|
|
```
|