Courseiva
Implement and maintain stateeasyMultiple ChoiceObjective-mapped

TF-004 Implement and maintain state Practice Question

Exhibit

$ terraform state list
aws_vpc.main
aws_subnet.public
aws_instance.web

Refer to the exhibit. What does the output indicate?

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

The state file tracks three resources

The `terraform state list` command lists all resources currently tracked in the state file. Here it shows three resources: a VPC, a subnet, and an EC2 instance.

Answer analysis

Option-by-option breakdown

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

  • The Terraform configuration defines three resources

    Why it's wrong here

    The `terraform state list` command exclusively queries the *Terraform state file*, which records the actual resources currently managed by Terraform. It does not directly inspect the `.tf` configuration files. The number of resources defined in the configuration might be different from what is tracked in the state file due to conditional resource creation, resource import operations, or resources being manually removed from the state without being destroyed. Therefore, this output cannot confirm the count of resources declared in the HCL code.

  • The state file tracks three resources

    Why this is correct

    The output of `terraform state list` explicitly displays the addresses of all resource instances that Terraform is currently managing within its state file for the active workspace. In the exhibit, three distinct resource addresses are clearly enumerated (e.g., `aws_instance.web`, `aws_s3_bucket.mybucket`, `null_resource.example`). This command's primary purpose is to provide an inventory of the resources recorded in the state, directly confirming that the state file is tracking exactly three resources.

  • Three providers are configured

    Why it's wrong here

    The `terraform state list` command is specifically designed to enumerate the *resource instances* recorded within the Terraform state file. It does not provide any information regarding the *providers* (e.g., AWS, Azure, Google) that are configured in the Terraform configuration or used by those resources. To inspect configured providers, one would typically examine the configuration files themselves or use a command like `terraform providers`. This output is solely about resources, not their underlying providers.

  • Three workspaces are in use

    Why it's wrong here

    The `terraform state list` command operates strictly within the context of the *currently selected workspace*, displaying resources managed by *that specific workspace's state file*. It provides no information about the total number of available workspaces or which other workspaces might exist. To manage, list, or switch between workspaces, dedicated commands such as `terraform workspace list` or `terraform workspace select` are required. This output is confined to the active state.

  • The plan will create three resources

    Why it's wrong here

    The `terraform state list` command provides a static inventory of the infrastructure currently known to Terraform, as recorded in its state file. It does not perform any comparison between the current state and the desired configuration, nor does it predict future actions. To determine what resources will be created, updated, or destroyed, the `terraform plan` command must be executed, which generates an execution plan based on the current configuration and the existing state. This output is purely informational about the current state, not a prediction of changes.

Visual reference

192.168.1.0 /24 256 addresses (254 usable) 192.168.1.0 /25 Subnet A 128 addr (126 usable) 192.168.1.128 /25 Subnet B 128 addr (126 usable) Borrowing 1 bit from host portion creates 2 subnets (/25)

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 →

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.