Apply formatting and style adjustments
Unlock the complete study guide + 1,040 practice questions across 16 full exams.
Bundled into the existing HashiCorp Certified: Terraform Associate premium course — no separate purchase.
14-day money-back guarantee — no questions asked.
Included in this chapter:
- What canonical formatting means
- Running fmt: write, check, diff, and scope
- Where fmt fits: pre-commit and CI
- Exam-pattern recognition
terraform fmt invocations at a glance
| Invocation | Writes files? | Non-zero exit if unformatted? | Typical use |
|---|---|---|---|
| terraform fmt | Yes, in place | No | Format the current directory before a commit |
| terraform fmt -recursive | Yes, including subdirectories | No | Format a tree of nested modules |
| terraform fmt -check | No | Yes | CI gate: fail when anything is unformatted |
| terraform fmt -diff | Yes, unless -check or -write=false | No | Show the changes fmt would make |
| terraform fmt - | No, writes to stdout | No | Format piped or generated HCL via stdin |
Decision tree
Cheat sheet
Unlock with Premium — includes all practice exams and the complete study guide.