What subcommand would you use to list all resources in the Terraform state?

Master the HashiCorp Terraform Test with these flashcards and multiple choice questions. Each question includes hints and explanations to prepare you effectively. Set yourself up for success!

The choice of "terraform state list" is correct because this subcommand is specifically designed to display all resources that are currently tracked within the Terraform state file. The state file is a crucial component in Terraform, as it maintains the mapping between the resources defined in your configuration files and the real resources managed in the cloud.

When you run "terraform state list", Terraform retrieves the state information and outputs a list of resource addresses, which includes both the resource types and their identifiers. This command is particularly useful for understanding what resources are currently managed by your Terraform configuration, verifying the state, or diagnosing issues.

In contrast, the other options do not serve the same purpose. "terraform show" is used to display detailed information about the Terraform state or a particular plan. While it may show resources, it does not specifically provide a list in a concise format. "terraform list" is not a valid command in the Terraform CLI, and "terraform resources" is also not a recognized command, further confirming that "terraform state list" is the correct choice for listing all resources in the Terraform state.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy