Skip to content

Commit 1a6fc27

Browse files
docs(standards): add terragrunt to terraform standards
Add terragrunt hclfmt as companion formatter, configuration section, Makefile targets, and pre-commit hook guidance to terraform standards. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3b4da57 commit 1a6fc27

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

content/docs/standards/_index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The following table shows the default tool for each concern per language. These
1414
| Concern | Python | Bash | Terraform | Ansible | Ruby | Go | JavaScript | Rust |
1515
|---|---|---|---|---|---|---|---|---|
1616
| Linter | ruff | shellcheck | tflint | ansible-lint | rubocop, reek | golangci-lint | eslint | clippy |
17-
| Formatter | ruff format | shfmt | terraform fmt | -- | rubocop | gofumpt | prettier | rustfmt |
17+
| Formatter | ruff format | shfmt | terraform fmt, terragrunt hclfmt | -- | rubocop | gofumpt | prettier | rustfmt |
1818
| Security | bandit, semgrep | -- | tfsec, checkov | -- | brakeman, bundler-audit | govulncheck | npm audit | cargo-audit, cargo-deny |
1919
| Tests | pytest | bats | terratest | molecule | rspec | go test | vitest | cargo test |
2020
| Type Check | mypy | -- | -- | -- | sorbet | -- | tsc | -- |
@@ -30,8 +30,8 @@ Each Makefile target runs the relevant tools for all languages declared in `.dev
3030
| Target | What It Runs |
3131
|---|---|
3232
| `make lint` | ruff check, shellcheck, tflint, ansible-lint, mypy, rubocop, reek, golangci-lint, eslint, tsc, clippy |
33-
| `make format` | ruff format --check, shfmt -d, terraform fmt -check, rubocop --check, gofumpt -d, prettier --check, cargo fmt --check |
34-
| `make fix` | ruff format, shfmt -w, terraform fmt, rubocop -a, gofumpt -w, prettier --write, cargo fmt |
33+
| `make format` | ruff format --check, shfmt -d, terraform fmt -check, terragrunt hclfmt --terragrunt-check, rubocop --check, gofumpt -d, prettier --check, cargo fmt --check |
34+
| `make fix` | ruff format, shfmt -w, terraform fmt, terragrunt hclfmt, rubocop -a, gofumpt -w, prettier --write, cargo fmt |
3535
| `make test` | pytest, bats, terratest, molecule, rspec, go test, vitest, cargo test |
3636
| `make security` | bandit, semgrep, tfsec, checkov, brakeman, bundler-audit, govulncheck, npm audit, cargo-audit, cargo-deny |
3737
| `make scan` | trivy, gitleaks (universal -- all projects) |
@@ -44,7 +44,7 @@ Each Makefile target runs the relevant tools for all languages declared in `.dev
4444
- [Coding Practices](/docs/standards/practices/) -- principles, error handling, testing, git workflow
4545
- [Python Standards](/docs/standards/python/) -- ruff, bandit, semgrep, pytest, mypy
4646
- [Bash Standards](/docs/standards/bash/) -- shellcheck, shfmt, bats
47-
- [Terraform Standards](/docs/standards/terraform/) -- tflint, terraform fmt, tfsec, checkov, terratest, terraform-docs
47+
- [Terraform Standards](/docs/standards/terraform/) -- tflint, terraform fmt, terragrunt hclfmt, tfsec, checkov, terratest, terraform-docs
4848
- [Ansible Standards](/docs/standards/ansible/) -- ansible-lint, molecule
4949
- [Ruby Standards](/docs/standards/ruby/) -- rubocop, brakeman, bundler-audit, rspec, reek, sorbet
5050
- [Go Standards](/docs/standards/go/) -- golangci-lint, gofumpt, govulncheck, go test

content/docs/standards/terraform.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: "Terraform Standards"
33
linkTitle: "Terraform"
44
weight: 30
5-
description: "Terraform tooling standards: tflint, terraform fmt, tfsec, checkov, terratest, and terraform-docs."
5+
description: "Terraform tooling standards: tflint, terraform fmt, terragrunt hclfmt, tfsec, checkov, terratest, and terraform-docs."
66
---
77

88
## Tools
@@ -11,6 +11,7 @@ description: "Terraform tooling standards: tflint, terraform fmt, tfsec, checkov
1111
|---|---|---|
1212
| Linting | tflint | Terraform-specific linting rules |
1313
| Formatting | terraform fmt | Canonical HCL formatting |
14+
| Formatting | terragrunt hclfmt | Terragrunt HCL formatting (when `terragrunt.hcl` present) |
1415
| Security | tfsec | Terraform-focused security scanning |
1516
| Security | checkov | Policy-as-code scanning |
1617
| Testing | terratest | Go-based infrastructure testing |
@@ -110,6 +111,20 @@ func TestTerraformModule(t *testing.T) {
110111

111112
The `tests/` directory must contain a `go.mod` file for the test module.
112113

114+
### terragrunt hclfmt
115+
116+
No config file required. Terragrunt is a companion tool that runs automatically when `terragrunt.hcl` files are detected in the project. It formats Terragrunt HCL files to a canonical style.
117+
118+
```bash
119+
# Check formatting (exits non-zero if files need formatting)
120+
terragrunt hclfmt --terragrunt-check
121+
122+
# Apply formatting
123+
terragrunt hclfmt
124+
```
125+
126+
Projects that do not use Terragrunt are unaffected — the formatter is silently skipped when no `terragrunt.hcl` files exist.
127+
113128
### terraform-docs
114129

115130
No config file required for default operation. Generates markdown documentation from Terraform module inputs, outputs, and descriptions.
@@ -134,6 +149,8 @@ terraform-docs markdown table . > README.md
134149
|---|---|---|
135150
| `make lint` | `tflint --recursive` | Lint all Terraform configurations |
136151
| `make format` | `terraform fmt -check -recursive` | Check formatting (no changes) |
152+
| `make format` | `terragrunt hclfmt --terragrunt-check` | Check Terragrunt formatting (when `terragrunt.hcl` present) |
153+
| `make fix` | `terragrunt hclfmt` | Apply Terragrunt formatting fixes (when `terragrunt.hcl` present) |
137154
| `make security` | `tfsec .` | Security scanning for Terraform |
138155
| `make security` | `checkov -d .` | Policy-as-code scanning |
139156
| `make test` | `cd tests && go test -v -timeout 30m` | Run terratest suite |
@@ -153,6 +170,8 @@ repos:
153170
hooks:
154171
- id: terraform_fmt
155172
- id: terraform_tflint
173+
# Uncomment if using Terragrunt:
174+
# - id: terragrunt_fmt
156175
```
157176

158177
### CI-Only (too slow for local hooks)
@@ -164,7 +183,7 @@ repos:
164183

165184
## Notes
166185

167-
- **`terraform fmt` is the only accepted formatter.** Do not use third-party HCL formatters.
186+
- **`terraform fmt` is the only accepted formatter** for `.tf` files. Do not use third-party HCL formatters. Terragrunt HCL files (`terragrunt.hcl`) are formatted by `terragrunt hclfmt`.
168187
- **Both `tfsec` and `checkov` run as part of `make security`.** They are complementary: tfsec focuses on Terraform-specific misconfigurations, checkov applies broader policy-as-code rules.
169188
- **`terraform-docs` runs as part of `make docs`.** Place `<!-- BEGIN_TF_DOCS -->` / `<!-- END_TF_DOCS -->` markers in your `README.md`.
170189
- **`terratest` tests are written in Go.** The `tests/` directory must contain a `go.mod` file.

0 commit comments

Comments
 (0)