TERRAFORM-ASSOCIATE-003 practice question 15 of 30

[Understand Terraform Basics and CLI] Which of these commands makes your code more human readable?

Full set: 226 questions
Answer options
A: Terraform validate
B: Terraform output
C: Terraform show
D: Terraform file
Correct Answer:
D (ASSUMING 'TERRAFORM FILE' IS A TYPO FOR 'TERRAFORM FMT')
Explanation

The question contains a likely typo in option D; the correct command is terraform fmt. The terraform fmt command is the standard tool used to rewrite Terraform configuration files to a canonical format and style. It recursively processes files in the current directory to ensure consistent indentation, spacing, and alignment. This makes the HCL code more human-readable and maintainable for developers working on the project, without changing the behavior of the configuration.

Why Incorrect

A. Terraform validate: This command checks for syntax errors and internal consistency but does not reformat the source code files for readability.
B. Terraform output: This command extracts and displays output values from the state file; it does not modify or format the configuration code.
C. Terraform show: This command presents a plan or state file in a human-readable format but does not reformat the source .tf files.

References

1. HashiCorp Developer - Terraform CLI

fmt command: "The terraform fmt command is used to rewrite Terraform configuration files to a canonical format and style." This directly supports the primary function of making code readable.

Source: HashiCorp

developer.hashicorp.com/terraform/cli/commands/fmt

2. HashiCorp Developer - Terraform CLI

validate command: "The terraform validate command validates the configuration files in a directory... Validation runs a series of checks..." This confirms its purpose is validation

not formatting.

Source: HashiCorp

developer.hashicorp.com/terraform/cli/commands/validate

3. HashiCorp Developer - Terraform CLI

show command: "The terraform show command is used to provide human-readable output from a state or plan file." This clarifies that it makes the output (plan/state) readable

not the source code itself.

Source: HashiCorp

developer.hashicorp.com/terraform/cli/commands/show

4. HashiCorp Developer - Terraform CLI

output command: "The terraform output command is used to extract the value of an output variable from the state file." This confirms its role is data extraction

not code formatting.

Source: HashiCorp

developer.hashicorp.com/terraform/cli/commands/output

Scroll to Top