TERRAFORM-ASSOCIATE-004 · Question #114
You have multiple team members collaborating on infrastructure as code (IaC) using Terraform, and want to apply formatting standards for readability. How can you format Terraform HCL (HashiCorp Config
The correct answer is A. Run the terraform fmt command during the code linting phase of your CI/CD process. 'terraform fmt' is the built-in Terraform command that automatically reformats all .tf files in the current directory (and optionally subdirectories with -recursive) to the canonical HCL style: consistent indentation, aligned equal signs within blocks, and standardized spacing. R
Question
Options
- ARun the terraform fmt command during the code linting phase of your CI/CD process
- BDesignate one person in each team to review and format everyone's code
- CManually apply two spaces indentation and align equal sign "=" characters in every Terraform file
- DWrite a shell script to transform Terraform files using tools such as AWK, Python, and sed
How the community answered
(30 responses)- A93% (28)
- C3% (1)
- D3% (1)
Explanation
'terraform fmt' is the built-in Terraform command that automatically reformats all .tf files in the current directory (and optionally subdirectories with -recursive) to the canonical HCL style: consistent indentation, aligned equal signs within blocks, and standardized spacing. Running it in CI/CD ensures every merged commit meets the style standard without relying on manual review or custom scripts. The other options are either error-prone manual processes or reinventions of functionality that Terraform already provides natively.
Topics
Community Discussion
No community discussion yet for this question.