HashiCorpHashiCorp
TA-002-P · Question #243
TA-002-P Question #243: Real Exam Question with Answer & Explanation
The correct answer is C: 2. HashiCorp's official Terraform style guide specifies 2 spaces per nesting level for indentation in configuration files.
Read, generate, and modify configuration
Question
When writing Terraform code, HashiCorp recommends that you use how many spaces between each nesting level?
Options
- A0
- B1
- C2
- D4
Explanation
HashiCorp's official Terraform style guide specifies 2 spaces per nesting level for indentation in configuration files.
Common mistakes.
- A. 0 spaces would mean no indentation at all, making nested blocks visually indistinguishable from top-level blocks and violating HashiCorp style conventions.
- B. 1 space is not the recommended indentation level; HashiCorp specifies 2 spaces as the standard for readability and consistency.
- D. 4 spaces is a common convention in other languages like Python, but Terraform's official style guide specifies 2 spaces, not 4.
Concept tested. HashiCorp Terraform style guide indentation standard
Reference. https://developer.hashicorp.com/terraform/language/style#indentation-and-formatting
Topics
#Terraform formatting#Code style#Indentation#Best practices
Community Discussion
No community discussion yet for this question.