HashiCorp Certified: Terraform Associate — Question 146
Which command should you run to check if all code in a Terraform configuration that references multiple modules is properly formatted without making changes?
Answer options
- A. terraform fmt -write=false
- B. terraform fmt -list -recursive
- C. terraform fmt -check -recursive
- D. terraform fmt -check
Correct answer: C
Explanation
The correct answer is C, as 'terraform fmt -check -recursive' checks the formatting of all code in the specified directory and its subdirectories without making any changes. Option A is incorrect because it uses '-write=false', which is not a valid flag for this command. Option B and D do not include the recursive check, limiting their effectiveness in verifying multiple modules.