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

Multiple team members are collaborating on infrastructure using Terraform and want to format their Terraform code following standard Terraform-style convention. How could they automatically ensure the code satisfies conventions?

    Correct Answer: A

    To ensure that Terraform code follows standard style conventions automatically, the terraform fmt command is the most appropriate option. This command formats the code in accordance with Terraform's style guidelines, ensuring consistency and readability. Running terraform fmt during the code linting phase of a CI/CD process ensures that the code is formatted correctly before it is merged, thus maintaining consistency across all team members' contributions.

Discussion
Oleg_golOption: A

By running terraform fmt during the code linting phase of your CI/CD process, you can automatically ensure that all Terraform files are formatted according to the standard conventions before any code is merged into the main branch. This helps to maintain a consistent code style and reduces the likelihood of errors caused by inconsistent formatting.