A team's lint job runs terraform fmt -check in the repository root and has passed on every pull request for months. A reviewer now finds that several files in modules/network/ use inconsistent indentation and alignment. The job's log shows no errors. What explains the missed files?
Choose one.
terraform fmt's scope: by default only the specified or current directory.
The documentation states that by default fmt only processes the specified or current directory, and -recursive also processes subdirectories. The job therefore checked only the root's .tf files. -check does return a non-zero exit status on findings, and fmt has no commit-aware or module-aware filtering.
- Note where the job runs and where the bad files live.
- Recall fmt's default scope is one directory.
- Recall -check does fail the job on findings it sees.
- Conclude the files were outside the scope; add -recursive.
Exam tip: No -recursive, no subdirectories: fmt -check from the root misses modules/.
Terraform Professional: CI/CD Pipelines and Deployment Strategies — the lesson that teaches this.