Terraform
Opinionated Terraform guidance, split by task. This file routes; the detail
lives in references/. Load only the reference for the task at hand.
| Task | Read |
|---|---|
Writing or reviewing HCL (style, layout, naming, variables, outputs, for_each, version pinning) |
references/style-guide.md (plus references/security.md) |
Writing or running module tests (.tftest.hcl, run/assert blocks, mock providers, CI) |
references/test.md (plus references/test/) |
Refactoring monolithic config into reusable modules (interfaces, moved state migration) |
references/refactor-module.md |
Authoring Terraform Stacks (.tfcomponent.hcl, .tfdeploy.hcl, deployments, linked Stacks) |
references/stacks.md (plus references/stacks/) |
Conventions
- Format and validate before every commit:
terraform fmt -recursivethenterraform validate. - Prefer
for_eachovercountfor multiple resources; reservecountfor conditional creation. - Every variable and output carries a
type(variables) and adescription; mark secretssensitive = true. - Pin
required_versionand provider versions; commit.terraform.lock.hcl, never state files or.terraform/.
Attribution: the reference bodies are adapted from HashiCorp agent-skills
(hashicorp/agent-skills, MPL-2.0; portions Copyright IBM Corp. 2026).