tf
What is a .tf file?
text/x-terraform
A .tf file is a Terraform configuration written in HCL. It declares infrastructure as blocks (terraform, provider, resource, data, variable, output, module, locals) whose bodies hold arguments and nested blocks, with values drawn from expressions, interpolation, and functions. Terraform reads every .tf file in a directory as one merged configuration, so ordering across files carries no meaning.
How to use a .tf file
Use an example .tf file to test HCL parsers, infrastructure linters and policy engines, and configuration migrators, checking block-and-label parsing, heredoc strings, expression references between resources, and that a deprecated-syntax file is flagged rather than silently accepted.
Download example .tf files
- Terraform Required Providers and BackendThe terraform settings block: a version constraint range, two pinned providers, a local backend, default tags, and a second aliased provider configuration. The fictional examplecloud provider means nothing resolves to a real service.
- Terraform Variables with Validation BlocksSeven Terraform variables covering string, number, map and a map(object) with an optional attribute and a default, plus two validation blocks with error messages. The sensitive variable's default is explicitly a SAMPLE note, not a credential.
- Terraform Resources with count and for_eachThe resource graph: a network, a for_each subnet set, a counted instance resource, a data source, and a bucket on an aliased provider. Both repetition meta-arguments appear, plus lifecycle and an explicit depends_on edge.
- Terraform Locals, for Expressions, and dynamic BlocksThe expression-heavy half of the stack: for expressions producing both a map and a filtered list, conditional expressions selecting whole objects, and a dynamic block that generates two firewall rules from a local list.
- Terraform Module Calls with Meta-ArgumentsThree module calls covering the shapes a dependency grapher has to handle: a local path with explicit provider passing, a versioned registry source under for_each, and a count-gated conditional module.
- Terraform Outputs and Splat ExpressionsFive Terraform outputs exercising a splat expression over a counted resource, a for expression over a for_each module, and a sensitive output that must stay redacted when propagated from a sensitive input.
- Terraform Configuration, Intentionally InvalidAn intentionally invalid Terraform configuration: an unclosed resource block, a colon where HCL needs an equals sign, a reference to an undeclared resource, and a resource block missing its second label. Four documented faults for a parser to report.