nerdexam
HashiCorp

TA-002-P · Question #131

Which one of the following command will rewrite Terraform configuration files to a canonical format and style.

The correct answer is D. terraform fmt. terraform fmt rewrites all .tf and .tfvars files in the current directory (and optionally recursively) to conform to the Terraform canonical style - consistent indentation, spacing, and formatting. It is analogous to gofmt for Go code. terraform graph (C) and terraform graph -h (

Use the Terraform CLI (terraform plan, apply, destroy, fmt, init, validate, workspace, import, taint, providers, output)

Question

Which one of the following command will rewrite Terraform configuration files to a canonical format and style.

Options

  • Aterraform graph -h
  • Bterraform init
  • Cterraform graph
  • Dterraform fmt

How the community answered

(40 responses)
  • A
    3% (1)
  • B
    3% (1)
  • C
    5% (2)
  • D
    90% (36)

Explanation

terraform fmt rewrites all .tf and .tfvars files in the current directory (and optionally recursively) to conform to the Terraform canonical style - consistent indentation, spacing, and formatting. It is analogous to gofmt for Go code. terraform graph (C) and terraform graph -h (A) generate a visual dependency graph of resources. terraform init (B) initializes a working directory by downloading providers and modules.

Topics

#Terraform CLI#terraform fmt#Configuration formatting#Canonical style

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice