Which Terraform command lists the resources currently tracked in the state file?

Prepare for the HashiCorp Terraform Associate Exam with quizzes, flashcards, and multiple-choice questions. Each question includes hints and explanations. Boost your confidence and ace your exam!

Multiple Choice

Which Terraform command lists the resources currently tracked in the state file?

Explanation:
To see what Terraform is currently tracking in its state, you want to list the resource addresses stored there. The command that does this is terraform state list. It prints each resource address (like module.foo.aws_instance.bar) that Terraform knows about in the current state, giving you a quick inventory of what Terraform would act on. Other commands have different roles: terraform show provides detailed information about a resource or the whole state, not just a simple list. terraform state pull fetches the raw state file from the backend as JSON. terraform refresh updates the state to reflect drift between real infrastructure and the configuration, but it doesn’t produce a simple list of resources.

To see what Terraform is currently tracking in its state, you want to list the resource addresses stored there. The command that does this is terraform state list. It prints each resource address (like module.foo.aws_instance.bar) that Terraform knows about in the current state, giving you a quick inventory of what Terraform would act on.

Other commands have different roles: terraform show provides detailed information about a resource or the whole state, not just a simple list. terraform state pull fetches the raw state file from the backend as JSON. terraform refresh updates the state to reflect drift between real infrastructure and the configuration, but it doesn’t produce a simple list of resources.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy