Skip to main content
In this lesson you’ll learn how to inspect Terraform state from the CLI. This is useful when you need to verify concrete resource IDs, network attributes, tags, or other values that Terraform has recorded after apply. The primary commands demonstrated here are:
  • 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

1. List resources in state

Begin by listing every resource Terraform currently manages in your state:
This output lists resource addresses you can use as arguments to 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, use terraform show. This prints resource blocks with all recorded attributes:
Note: For large states this output can be verbose. When possible, scope your inspection to a specific resource address to reduce noise.

3. Inspect a single resource from state

To view only one resource’s recorded attributes, run terraform state show with a resource address printed by terraform state list. For example, inspect the EC2 instance:
This output shows concrete values (IDs, networking details, tags) exactly as stored in the Terraform state.

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:
Then inspect the private subnet:
This reveals the subnet ID, owner, tagging, region, and its associated VPC.
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 list to enumerate resource addresses present in the state.
  • Use terraform state show <address> to inspect a single resource’s recorded attributes.
  • Use terraform show to 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.

Watch Video