Skip to main content
In this lesson you’ll learn how to inspect Terraform state with the Terraform CLI. We’ll focus on two primary commands:
  • terraform state list — list resource addresses recorded in the state
  • terraform state show — display detailed attributes for a single resource in the state
Use terraform show (without the state subcommand) to print an entire state file or a saved plan file. Use terraform state show <ADDRESS> when you want details about a single resource recorded in the current state.
Use terraform show to dump a full state or plan file. Use terraform state show <ADDRESS> when you want a focused view of one resource from the current state.

Quick reference — commands

1. List resources in the state

Run terraform state list to see all resource addresses Terraform currently tracks:
Each line is a resource address you can pass to terraform state show for more detail. For example, to inspect the EC2 instance attributes you would use aws_instance.web.

2. Inspect the entire state (terraform show)

terraform show prints the contents of the current state or a plan file. This is useful for a broad overview but can be verbose. Example (truncated):
Because terraform show dumps everything, it’s often easier to inspect a single resource with terraform state show.

3. Inspect a single resource (terraform state show)

First run terraform state list to find the exact address you want. Then run:
Example: show the EC2 instance aws_instance.web:
This output includes every attribute Terraform knows about the instance: AMI, ARN, instance ID, network info, tags, and more. Example: show the private subnet aws_subnet.private:
Use terraform state list to locate the exact address, then terraform state show <address> to retrieve that resource’s details. This is the fastest way to inspect state for a single resource.
Tip: Pipe terraform state list into tools like grep to quickly find resources, for example: terraform state list | grep aws_instance.

Watch Video