<commit_before>---
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" {
    filename = "init.tpl"

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

```

## Argument Reference

The following arguments are supported:

* `filename` - (Required) The filename for the template. Use path variables
    (documented in the interpolation section) to specify what the path is
    relative to.

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

## Attributes Reference

The following attributes are exported:

* `filename` - 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](/docs/configuration/interpolation.html), under the "Templates" section.<commit_msg>docs: clarify template_file path information<commit_after>---
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" {
    filename = "${path.module}/init.tpl"

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

```

## Argument Reference

The following arguments are supported:

* `filename` - (Required) The filename for the template. Use [path
    variables](/docs/configuration/interpolation.html#path-variables) to make
    this path relative to different path roots.

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

## Attributes Reference

The following attributes are exported:

* `filename` - 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](/docs/configuration/interpolation.html), under the "Templates" section.
{'fraction_non_alphanumeric': 0.10583941605839416, 'fraction_numerical': 0.0, 'mean_word_length': 4.147887323943662, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '295120', 'n_tokens_mistral': 616, 'n_tokens_neox': 599, 'n_words': 215}