Courseiva
Implement and maintain stateeasyMultiple ChoiceObjective-mapped

TF-004 Implement and maintain state Practice Question

Which command can be used to see the current state of a specific resource in the Terraform state?

⚠ Common exam trap

The Terraform exam often tests the distinction between listing resources (`terraform state list`) and viewing a specific resource's details (`terraform state show`), leading candidates to confuse the two commands when asked for a targeted state inspection.

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 display the attributes and current state of a single resource as recorded in the Terraform state file. This allows you to inspect the exact values Terraform is tracking for that resource, which is essential for debugging drift or understanding the current infrastructure representation.

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 <resource>`

    Why this is correct

    This command is precisely designed to display the current attributes and values of a single, specific resource as recorded in the Terraform state file. By providing the resource's address (e.g., aws_instance.web), it retrieves and outputs all its managed properties, offering a detailed snapshot of that particular infrastructure component's state. This is invaluable for debugging, auditing, or verifying the configuration of an individual resource.

  • `terraform output`

    Why it's wrong here

    The terraform output command is used to display the values of output variables defined within your Terraform configuration. These outputs are explicitly declared to expose specific data points, such as an IP address or a DNS name, from your managed infrastructure. It does not provide a comprehensive view of the entire state of a resource or its internal attributes, but rather only the data points you've chosen to export.

  • `terraform state list`

    Why it's wrong here

    While terraform state list interacts with the state file, its purpose is to enumerate all resources currently tracked by Terraform, displaying their full resource addresses (e.g., aws_vpc.main). This command provides a high-level overview of the resources managed within the state, but it explicitly does not show the detailed attributes or current values for any of those resources. It merely lists their identifiers, not their "current state of a spec."

  • `terraform show`

    Why it's wrong here

    The terraform show command is primarily used to inspect a Terraform plan file generated by terraform plan or to display the entire contents of a state file in a human-readable format. When used without arguments, it defaults to showing the current working directory's state. However, it lacks the capability to filter and display the detailed attributes of a single, specific resource directly from the active state, making it unsuitable for inspecting a "spec."

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.