Exam Terraform Associate All QuestionsBrowse all questions from this exam
Question 35

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 Configuration Language) code according to standard Terraform style convention?

    Correct Answer: A

    To format Terraform HCL code according to standard Terraform style convention, the most efficient method is to run the 'terraform fmt' command. This command automatically formats Terraform configuration files to ensure they adhere to the style conventions, such as correct indentation and alignment of equal signs. This approach ensures consistency and saves time compared to manual formatting or custom scripts.

Discussion
vitasacOption: A

Yes Answer A

calebvarOption: A

correct answer is A

campsOption: A

A. Run the terraform fmt command during the code linting phase of your CI/CD process. Terraform provides a command called terraform fmt that can be used to automatically format Terraform HCL code according to the standard Terraform style convention. Running this command on your codebase during the code linting phase of your CI/CD process can ensure that your code is formatted consistently across your team and conforms to the standard Terraform style convention.

AwadhOption: A

A is the correct answer, who is writing the answers

Shane_COption: A

Now they have to be joking. The only reasonable answer is A. Everything else is just nonsense

nickyop

Yes, thank you!

nickyopOption: A

Okay, as obvious as the option A is the correct answer, here's one question. What happens if such questions arise in the terraform exam where they have the wrong answers saved as the right ones? For example, in the above question, if we choose the most voted option in the exam, we'll lose 1 mark just because the right answer is C according to the system?? And FYI, I have already undergone one attempt for the exam which I was certain that I would pass because it went pretty well but I failed by 2%. And I know for sure it is only because of such contradictory questions! @Hashicorp please settle such questions once and for all!

AkaAka4

Why are you even tagging Hashicorp here... do you think they will see your comment😂

ghostGuiggsOption: A

A is the answer

Tyler2023Option: C

The answer C is correct You can manually format your TF configuration to follow the Style Conventions Option A doesn't make any sense, why you run the terraform fmt in CI/CI process? that will only format the copy of the configuration in the remote agent that is running your configuration files, it doesn't modify your source codes in version control system. Option C followed the Terraform style convention, but it only do it manually https://developer.hashicorp.com/terraform/language/syntax/style

Clapton79

Pull Request is a CI/CD process and it can format code and it does modify your version control.

nickyop

Referring the link you have shared, I think you missed a note where they have mentioned "You can enforce these conventions automatically by running terraform fmt."

gofavad926Option: A

A for sure

vc1011Option: A

ITs very evident A

Ni33Option: A

A is correct

Ni33Option: A

A is the correct answer

Bluemoon22Option: A

A, by using terraform fmt command

connecttozeeOption: A

A is correct

Power123Option: A

A is correct

hasanuckunOption: A

answer is a

alexsandroeOption: A

FMT helped de code