Courseiva
Use Terraform outside the core workfloweasyMultiple ChoiceObjective-mapped

TF-004 Use Terraform outside the core workflow Practice Question

A developer wants to see the list of resources currently managed by Terraform in the state file. Which command should they use?

⚠ Common exam trap

Candidates often confuse `terraform show` (which dumps the full state) with `terraform state list` (which provides a concise, filtered list of resource addresses), leading them to pick C instead of D.

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 list

`terraform state list` is the dedicated command to list all resources tracked in the Terraform state file. It reads the state directly and outputs the resource addresses (e.g., `aws_instance.web`), giving the developer a clear view of what Terraform currently manages.

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 graph

    Why it's wrong here

    The `terraform graph` command generates a visual representation of the dependency graph for resources defined in your configuration. It outputs the graph in DOT format, which can then be rendered by tools like Graphviz to show how resources depend on each other. While it implicitly shows which resources exist as nodes in the graph, its primary purpose is to illustrate their interconnections and execution order, not to provide a simple textual list of managed resources. Therefore, it does not directly fulfill the request to simply list resources.

  • terraform output

    Why it's wrong here

    The `terraform output` command is specifically designed to display the values of output variables defined within your Terraform configuration. These outputs are typically used to extract important information, such as IP addresses, DNS names, or connection strings, from the deployed infrastructure after `terraform apply` has completed. It does not provide a comprehensive list of all managed resources within the state file; rather, it only shows the explicitly defined output values, making it unsuitable for enumerating all resources.

  • terraform show

    Why it's wrong here

    The `terraform show` command displays the current state of the infrastructure managed by Terraform, or the contents of a saved plan file, in a human-readable format. When used with the state file, it presents a highly detailed view of all resources, their attributes, and their current values, including sensitive data if not properly redacted. While it technically contains the resource names, its output is verbose and includes extensive configuration details for each resource, making it an inefficient and unsuitable tool for simply generating a concise list of resource identifiers.

  • terraform state list

    Why this is correct

    The `terraform state list` command is precisely designed to enumerate all resources and data sources currently tracked within the Terraform state file. It provides a clean, hierarchical list of resource addresses (e.g., `aws_instance.web`, `aws_s3_bucket.my_bucket`), making it the most direct and efficient way to see exactly which infrastructure components Terraform is managing. This command directly addresses the developer's need for a simple, concise list of managed resources without displaying their full configurations.

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.