Hashicorp Certified Terraform Associate 003 · Free Practice Question Easy

Question 6

When several single-line arguments appear on consecutive lines at the same nesting level in Terraform configuration files, what formatting convention does HashiCorp recommend?

  • A

    align the equals signs


  • B

    put arguments in alphabetical order


  • C

    place all arguments using a variable at the top


  • D

    place a space in between each line


Reveal correct answer

Correct answer: A

Explanation

HashiCorp style conventions suggest that you align the equals sign for consecutive arguments for easing readability for configurations:



Notice how the equal (=) signs are aligned, even though the arguments are of different lengths.


https://developer.hashicorp.com/terraform/language/syntax/style

A. HashiCorp recommends aligning the equals signs for better readability and consistency in the code. This helps in quickly identifying and understanding the key-value pairs in the configuration.

B. Putting arguments in alphabetical order is not a recommendation from HashiCorp. It may not provide any significant benefit in terms of readability or maintainability of the Terraform configuration.

C. Placing all arguments using a variable at the top is not a recommendation from HashiCorp. While using variables can improve code maintainability, there is no specific guideline to place all arguments using variables at the top.

D. HashiCorp does not recommend placing a space in between each line for consecutive arguments with single-line values at the same nesting level. This practice may introduce unnecessary whitespace and reduce code compactness.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need