TERRAFORM-ASSOCIATE-003 practice question 29 of 30

[Understand Terraform Basics and CLI] Which of the following commands would you use to access all of the attributes and details of a resource managed by Terraform?

Full set: 226 questions
Answer options
A: terraform state list ‘provider_type.name’
B: terraform state show ‘provider_type.name’ Correct answer
C: terraform get ‘provider_type.name’
D: terraform state list
Correct Answer:
B. terraform state show ‘provider_type.name’
Explanation

The terraform state show command is used to inspect a specific resource within the Terraform state file. When provided with the resource's address (in the format resourcetype.resourcename), it outputs all the stored attributes and their values for that particular resource. This allows for a detailed view of a single managed resource, which directly addresses the user's need to access all its attributes and details.

Why Incorrect

A. terraform state list ‘providertype.name’ This command lists resource instances. Providing an address filters the list to that specific resource, but it only outputs the address itself, not its detailed attributes.
C. terraform get ‘providertype.name’ The terraform get command is used to download and update modules for the configuration. It does not interact with the state file to show resource attributes.
D. terraform state list This command lists the addresses of all resources managed in the current state file. It does not display the detailed attributes of any individual resource.

References

1. HashiCorp Terraform Documentation, terraform state show command: "The terraform state show command is used to show the attributes of a single resource in the Terraform state." The documentation provides the usage as terraform state show [options] ADDRESS, confirming this is the correct command for the task. (Source: HashiCorp, Terraform CLI Documentation, state show subcommand).

2. HashiCorp Terraform Documentation, terraform state list command: "The terraform state list command is used to list resources within a Terraform state... The output format is the resource address." This confirms that list only shows addresses, not details. (Source: HashiCorp, Terraform CLI Documentation, state list subcommand).

3. HashiCorp Terraform Documentation, terraform get command: "The terraform get command downloads and installs modules needed for the configuration." This confirms its purpose is related to modules, not resource inspection. (Source: HashiCorp, Terraform CLI Documentation, get command).

Scroll to Top