nerdexam
HashiCorp

TA-002-P · Question #350

Running terraform fmt without any flags in a directory with Terraform configuration files will check the formatting of those files without changing their contents.

The correct answer is B. False. False. Running 'terraform fmt' without any flags rewrites Terraform configuration files in place to match the canonical style. It DOES modify file contents. To only check formatting without making changes (useful in CI pipelines), you must use the '-check' flag: 'terraform fmt…

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

Question

Running terraform fmt without any flags in a directory with Terraform configuration files will check the formatting of those files without changing their contents.

Options

  • ATrue
  • BFalse

How the community answered

(33 responses)
  • A
    12% (4)
  • B
    88% (29)

Explanation

False. Running 'terraform fmt' without any flags rewrites Terraform configuration files in place to match the canonical style. It DOES modify file contents. To only check formatting without making changes (useful in CI pipelines), you must use the '-check' flag: 'terraform fmt -check'. This exits with a non-zero status code if any files are not properly formatted, without altering them.

Topics

#terraform fmt#CLI commands#Code formatting#Default behavior

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice