Terraform-Associate-004 practice question 11 of 35
Running terraform fmt without any flags in a directory with Terraform configuration files will check the formatting of those files, but will never change their contents.
Full set: 360 questionsThe statement is incorrect. The primary function of the terraform fmt command, when run without any flags, is to scan the current directory and rewrite Terraform configuration files to a canonical format and style. This action directly modifies the contents of any files that do not conform to the standard formatting. The behavior of only checking for formatting issues without changing the files is achieved by using the -check flag.
The statement claims that terraform fmt will "never change their contents" by default. This is the opposite of its actual default behavior, which is to reformat and thus change the files in place.
1. HashiCorp Developer Documentation, Terraform CLI, fmt Command:
Location: https://developer.hashicorp.com/terraform/cli/commands/fmt
Quote/Paraphrase: The documentation's opening sentence states, "The terraform fmt command is used to rewrite Terraform configuration files to a canonical format and style." This explicitly confirms that the command's purpose is to change file content.
Quote/Paraphrase for -check flag: The documentation describes the -check option as follows: "Check if the input is already formatted. Exit with a non-zero status code if the input is not formatted." This distinguishes the "checking" behavior as a non-default option.
Keep practicing
Take the free Terraform-Associate-004 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other Terraform-Associate-004 practice questions
- Question 1You should run terraform fnt to rewrite all Terraform configurations within the current w…
- Question 2Module variable assignments are inherited from the parent module and you do not need to e…
- Question 3terraform validate confirms thesyntaxof Terraform files.
- Question 4Using the terraform state rm command against a resource will destroy it.
- Question 5Variables declared within a module are accessible outside of the module.
- Question 6terraform init retrieves and caches the configuration for all remote modules.
