terraform fmt
The command that rewrites .tf files into Terraform's one standard layout; it never looks at real infrastructure.
In more detail
It fixes indentation to two spaces per level and lines up the equals signs of neighbouring arguments, and there are no options to change the style. With -check it rewrites nothing and exits with a non-zero exit code if any file needs formatting, which is what a pipeline wants. With -recursive it also formats subdirectories such as modules.
Examples
terraform fmtterraform fmt -check -recursiveRelated terms
- terraform validate — The command that checks a configuration is internally consistent, such as correct syntax, types and references, without contacting any real infrastructure.
- exit code — A number a process returns when it finishes: 0 means success, anything else means something went wrong.
- continuous integration — Automatically building and testing every change as soon as it is pushed, so problems are caught early.
- diff — A listing of the differences between two versions of something, such as two files, two commits or two screenshots.
Taught in
- Installing Terraform And Meeting The CLI — Infrastructure as Code with Terraform
- Writing Your First Configuration In HCL — Infrastructure as Code with Terraform
- Running Terraform In CI — Infrastructure as Code with Terraform
- Native Testing With Tftest Files — Infrastructure as Code with Terraform
- Provider Mocking For Tests — Infrastructure as Code with Terraform
- Policy As Code With OPA — Infrastructure as Code with Terraform
- Releasing The Real Cloud Artifact — Infrastructure as Code with Terraform
- Validate, Format, Destroy, And The Flags That Bend A Plan — HashiCorp Terraform Associate (004) Exam Prep
- Importing What Terraform Did Not Build — HashiCorp Terraform Associate (004) Exam Prep
- Moved And Removed Blocks: Refactoring Without Rebuilding — HashiCorp Terraform Associate (004) Exam Prep
- Trap Sprint: Twelve Answers That Are Almost True — HashiCorp Terraform Associate (004) Exam Prep
- The Full Mock: Sixty Minutes, Eight Areas, One Plan For The Last Week — HashiCorp Terraform Associate (004) Exam Prep