2015-05-08 03:20:05 +02:00
|
|
|
---
|
|
|
|
layout: "template"
|
|
|
|
page_title: "Template: template_file"
|
|
|
|
sidebar_current: "docs-template-resource-file"
|
|
|
|
description: |-
|
|
|
|
Renders a template from a file.
|
|
|
|
---
|
|
|
|
|
|
|
|
# template\_file
|
|
|
|
|
|
|
|
Renders a template from a file.
|
|
|
|
|
|
|
|
## Example Usage
|
|
|
|
|
|
|
|
```
|
|
|
|
resource "template_file" "init" {
|
2015-11-17 23:45:08 +01:00
|
|
|
template = "${file("${path.module}/init.tpl")}"
|
2015-05-08 03:20:05 +02:00
|
|
|
|
|
|
|
vars {
|
|
|
|
consul_address = "${aws_instance.consul.private_ip}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
## Argument Reference
|
|
|
|
|
|
|
|
The following arguments are supported:
|
|
|
|
|
2015-11-13 18:07:02 +01:00
|
|
|
* `template` - (Required) The contents of the template. These can be loaded
|
|
|
|
from a file on disk using the [`file()` interpolation
|
|
|
|
function](/docs/configuration/interpolation.html#file_path_).
|
2015-05-08 03:20:05 +02:00
|
|
|
|
|
|
|
* `vars` - (Optional) Variables for interpolation within the template.
|
|
|
|
|
2015-11-13 18:07:02 +01:00
|
|
|
The following arguments are maintained for backwards compatibility and may be
|
|
|
|
removed in a future version:
|
|
|
|
|
|
|
|
* `filename` - __Deprecated, please use `template` instead_. The filename for
|
|
|
|
the template. Use [path variables](/docs/configuration/interpolation.html#path-variables) to make
|
|
|
|
this path relative to different path roots.
|
|
|
|
|
2015-05-08 03:20:05 +02:00
|
|
|
## Attributes Reference
|
|
|
|
|
|
|
|
The following attributes are exported:
|
|
|
|
|
2015-11-13 18:07:02 +01:00
|
|
|
* `template` - See Argument Reference above.
|
2015-05-08 03:20:05 +02:00
|
|
|
* `vars` - See Argument Reference above.
|
|
|
|
* `rendered` - The final rendered template.
|
|
|
|
|
2015-05-27 12:22:52 +02:00
|
|
|
## Template files syntax
|
|
|
|
|
|
|
|
The syntax of the template files is [documented here](/docs/configuration/interpolation.html), under the "Templates" section.
|