Courseiva
Read, generate and modify configurationeasyMultiple SelectObjective-mapped

TF-004 Read, generate and modify configuration Practice Question

Which TWO of the following commands can be used to read and inspect the current Terraform state? (Select TWO.)

⚠ Common exam trap

In Terraform, it's easy to confuse commands that inspect state versus those that read configuration or outputs. The trap here is that candidates may think `terraform output` or `terraform plan` are state inspection commands, but they serve different purposes: `output` shows output values, and `plan` creates a diff against state, not a direct state read.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

terraform state show

`terraform state show` is correct because it displays the attributes and metadata of a specific resource within the Terraform state file, allowing you to inspect the current state of that resource. `terraform state list` is correct because it lists all resources tracked in the state file, providing a high-level overview of what Terraform is managing. Both commands directly read and inspect the state without modifying it.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • terraform state show

    Why this is correct

    The terraform state show <ADDRESS> command is used to display the attributes of a single resource instance or module as recorded in the Terraform state file. It provides a detailed, human-readable output of the resource's current state, including its configuration and any computed values. This command is essential for inspecting the exact properties of a managed infrastructure component without interacting with the live cloud provider.

  • terraform validate

    Why it's wrong here

    The terraform validate command performs checks on the configuration files in the current directory to ensure they are syntactically valid and internally consistent. It verifies that variables are defined, providers are configured correctly, and resource arguments conform to their expected types. However, this command does not interact with the Terraform state file or the remote infrastructure, making it unsuitable for reading existing state information.

  • terraform state list

    Why this is correct

    The terraform state list command provides a comprehensive list of all resources and modules currently tracked within the Terraform state file. This command is particularly useful for gaining an overview of the infrastructure managed by a given Terraform configuration, showing the addresses of each component. It directly reads the state file to enumerate all managed objects, making it a primary tool for understanding the contents of the state.

  • terraform output

    Why it's wrong here

    The terraform output command is designed to display the values of output variables explicitly defined in the Terraform configuration. While these outputs might derive from resource attributes, this command does not provide a direct view of the entire Terraform state file or the detailed attributes of individual resources. Its scope is limited to presenting only the specific values designated as outputs by the configuration author.

  • terraform plan

    Why it's wrong here

    The terraform plan command generates an execution plan by comparing the desired state defined in the configuration with the actual state of the infrastructure and the current Terraform state file. While it reads the state file as part of this comparison, its primary purpose is to show what changes would be made to reach the desired state, not to display the raw contents or details of the existing state file itself. It focuses on future actions rather than current inventory.

About these practice questions

One of 428 original TF-004 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This TF-004 practice question is part of Courseiva's free HashiCorp certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the TF-004 exam.