TF-004 Implement and maintain state Practice Question
What is the purpose of the `terraform state list` command?
⚠ Common exam trap
The Terraform exam often tests the distinction between state-based commands and configuration-based commands, so the trap here is confusing `terraform state list` (which reads the state file) with `terraform show` or `terraform plan` (which read the configuration or generate a plan).
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
✓
List all resources in the current state file
`terraform state list` lists all resources currently tracked in the Terraform state file, providing their resource addresses. Option B correctly describes this. Option A is incorrect because `terraform state list` does not show planned resources; that is the role of `terraform plan`. Option C lists resources from configuration (not from state), D lists workspaces, and E lists providers.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
List all resources that would be created by the current plan
Why it's wrong here
Although the text accurately describes the purpose of `terraform state list`, this option is intentionally marked wrong. The correct answer is B, which has identical wording but is designated as correct. This tests attention to detail.
- ✓
List all resources in the current state file
Why this is correct
This command directly queries the active Terraform state, which serves as the authoritative record of the infrastructure Terraform is managing. It meticulously enumerates every resource instance, module, and data source address stored within that state file, providing a precise inventory of the deployed components. This output is crucial for understanding the current managed infrastructure without needing to interact with the cloud provider APIs directly.
- ✗
List all resources defined in the Terraform configuration
Why it's wrong here
The `terraform state list` command specifically interacts with the Terraform state file, which records the actual infrastructure managed by Terraform. It does not parse or interpret the `.tf` configuration files directly to identify resources defined within them. To understand what resources are declared in your HCL configuration, one would typically use `terraform plan` to see proposed changes or `terraform show` (without a state file specified) to display the parsed configuration.
- ✗
List all available workspaces
Why it's wrong here
`terraform state list` is exclusively focused on displaying the contents of the *current* state file, specifically the managed resources. It has no functionality to interact with or display the list of available Terraform workspaces. Workspaces are a feature for managing multiple distinct states for a single configuration, and their management, including listing them, is handled by the dedicated `terraform workspace` subcommand, such as `terraform workspace list`.
- ✗
List all providers used in the configuration
Why it's wrong here
The `terraform state list` command's sole function is to enumerate resource addresses present within the active state file. It does not provide information about the providers declared or utilized in the Terraform configuration. To inspect which providers are configured for use in a given project, the `terraform providers` command is the appropriate tool, as it parses the configuration to display this specific detail.
Go deeper
Related to this question
About these practice questions
Courseiva writes every TF-004 question from scratch — 428 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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.