Files
opentf/website/source/docs/providers/template/d/file.html.md
Martin Atkins 861ac536dd provider/template: convert resources to data sources
The template resources don't actually need to retain any state, so they
are good candidates to be data sources.

This includes a few tweaks to the acceptance tests -- now configured to
run as unit tests -- since it seems that they have been slightly broken
for a while now. In particular, the "update" cases are no longer tested
because updating is not a meaningful operation for a data source.
2016-07-08 17:11:17 +01:00

1.4 KiB

layout, page_title, sidebar_current, description
layout page_title sidebar_current description
template Template: template_file docs-template-datasource-file Renders a template from a file.

template_file

Renders a template from a file.

Example Usage

data "template_file" "init" {
    template = "${file("${path.module}/init.tpl")}"

    vars {
        consul_address = "${aws_instance.consul.private_ip}"
    }
}

Argument Reference

The following arguments are supported:

  • template - (Required) The contents of the template. These can be loaded from a file on disk using the file() interpolation function.

  • vars - (Optional) Variables for interpolation within the template.

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 to make this path relative to different path roots.

Attributes Reference

The following attributes are exported:

  • template - See Argument Reference above.
  • vars - See Argument Reference above.
  • rendered - The final rendered template.

Template files syntax

The syntax of the template files is documented here, under the "Templates" section.