nerdexam
HashiCorp

TERRAFORM-ASSOCIATE-004 · Question #14

What is the Terraform style convention for indenting a nesting level compared to the one above it?

The correct answer is B. With two spaces. The official Terraform style conventions, documented in the HashiCorp style guide, specify that each nesting level should be indented by two spaces relative to its parent block. Tabs are not used (A). Four spaces (C) is the Python convention but not Terraform's. Three spaces (D)

Submitted by rachelw· Apr 18, 2026Work with Terraform Configurations

Question

What is the Terraform style convention for indenting a nesting level compared to the one above it?

Options

  • AWith a tab
  • BWith two spaces
  • CWith four spaces
  • DWith three spaces

How the community answered

(37 responses)
  • A
    5% (2)
  • B
    89% (33)
  • C
    3% (1)
  • D
    3% (1)

Explanation

The official Terraform style conventions, documented in the HashiCorp style guide, specify that each nesting level should be indented by two spaces relative to its parent block. Tabs are not used (A). Four spaces (C) is the Python convention but not Terraform's. Three spaces (D) is non-standard. Consistent use of two-space indentation is enforced by terraform fmt, which automatically reformats configuration files to comply with the style guide.

Topics

#HCL formatting#Code conventions#Indentation#Style guide

Community Discussion

No community discussion yet for this question.

Full TERRAFORM-ASSOCIATE-004 Practice