Which command lists resources in the Terraform state?

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 command lists resources in the Terraform state?

Explanation:
Listing resources in the Terraform state is about querying the state file to see what Terraform is currently managing. The best command to do this is "terraform state list" because it directly reads the state and prints the addresses of all resources Terraform knows about. This helps you understand which resources are tracked and will be affected by future operations. In contrast, the other commands perform actions rather than inspection: "terraform destroy" removes resources, "terraform fmt" formats your configuration files, and "terraform apply" creates or updates resources to match your configuration.

Listing resources in the Terraform state is about querying the state file to see what Terraform is currently managing. The best command to do this is "terraform state list" because it directly reads the state and prints the addresses of all resources Terraform knows about. This helps you understand which resources are tracked and will be affected by future operations.

In contrast, the other commands perform actions rather than inspection: "terraform destroy" removes resources, "terraform fmt" formats your configuration files, and "terraform apply" creates or updates resources to match your configuration.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy