TF-004 Implement and maintain state Practice Question
A user wants to inspect the current attributes of a specific resource in the Terraform state. Which command should they use?
⚠ Common exam trap
Terraform often tests the distinction between commands that list resources (`state list`) versus those that show detailed attributes (`state show`), and candidates frequently confuse `terraform show` (which dumps the entire state) with the resource-specific `terraform state show`.
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 <resource>
The `terraform state show <resource>` command is specifically designed to inspect the current attributes of a single resource within the Terraform state file. It reads the state directly and outputs the resource's attributes in a human-readable format, making it the correct tool for this task.
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 list <resource>
Why it's wrong here
The `terraform state list` command is designed to display a list of all resource addresses currently managed by the Terraform state file. It does not accept a resource argument to filter or show details for a specific resource; providing one would result in a syntax error or unexpected behavior. Its purpose is to provide an overview of managed resources by their logical addresses, not to output their detailed attributes.
- ✗
terraform output
Why it's wrong here
The `terraform output` command is used to display the values of output variables explicitly defined within the Terraform configuration. These outputs are user-defined values, often derived from resource attributes, but they do not represent the full set of current attributes for a specific resource. This command provides a curated view of specific data points, not a comprehensive inspection of a resource's internal state.
- ✓
terraform state show <resource>
Why this is correct
The `terraform state show <resource>` command precisely fulfills the requirement by displaying the complete, current state data for a specified resource address. This includes all recorded attributes, dependencies, and metadata as stored in the Terraform state file. It provides a detailed snapshot of the resource's last known configuration and status, making it ideal for inspecting specific resource attributes.
- ✗
terraform plan
Why it's wrong here
The `terraform plan` command's primary function is to compare the desired state defined in the configuration with the current state of the infrastructure and the Terraform state file, then propose a set of changes. While it shows *proposed* attribute values for resources that will be created, updated, or destroyed, it does not directly display the *current* attributes of an existing resource in a detailed, inspectable format. Its output focuses on the delta, not the comprehensive current state.
- ✗
terraform show
Why it's wrong here
The `terraform show` command, when executed without specific arguments or pointing to a plan file, displays the entire contents of the current Terraform state file. While the attributes of a specific resource are indeed contained within this output, `terraform show` lacks the ability to filter and present only the details of a single resource. This makes it less precise and often overwhelming for the task of inspecting a *specific* resource's attributes compared to `terraform state show`.
Go deeper
Related to this question
About these practice questions
This TF-004 question is part of Courseiva's 428-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
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.