terraform state list— enumerate resource addresses stored in the state.terraform state show— display detailed attributes for a single resource from the state.terraform show— render the full state (or a saved plan file) in a human-readable format.
Use
terraform state list to discover resource addresses, then pass one of those addresses to terraform state show to inspect that resource in detail.Quick command reference
| Command | Purpose | Example |
|---|---|---|
terraform state list | List all resource addresses recorded in the state | terraform state list |
terraform state show <address> | Show detailed attributes for a single resource | terraform state show aws_instance.web |
terraform show [planfile] | Dump the full state or a saved plan in human-readable form | terraform show or terraform show plan.out |
1. List resources in state
Begin by listing every resource Terraform currently manages in your state:terraform state show. The addresses reflect the resource type and name from your configuration (for example, aws_instance.web).
2. Inspect the entire state (or a saved plan)
When you want a full dump of state data or want to inspect a saved plan file, useterraform show. This prints resource blocks with all recorded attributes:
3. Inspect a single resource from state
To view only one resource’s recorded attributes, runterraform state show with a resource address printed by terraform state list. For example, inspect the EC2 instance:
4. Example: inspect a subnet
A common workflow is to list resources and then inspect a specific subnet to verify IDs, tagging, and VPC association. List resources:Avoid editing the state file manually. If you need to adjust state (move, remove, or import resources), use Terraform state subcommands like
terraform state mv, terraform state rm, or terraform import to keep state consistent and avoid corruption.Summary
- Use
terraform state listto enumerate resource addresses present in the state. - Use
terraform state show <address>to inspect a single resource’s recorded attributes. - Use
terraform showto produce a full, human-readable dump of the entire state or a saved plan. - Prefer Terraform state subcommands for state modifications; do not edit state files by hand.
Links and references
- Terraform State Commands — HashiCorp Documentation
- terraform show — Terraform CLI
- State management and backends — Terraform Docs