Skip to content
Latchkey

terraform state list: Usage & Common CI Errors

See every resource Terraform is tracking, by address.

terraform state list prints the resource addresses recorded in state. It is the starting point for surgical state work - show, mv, rm, and import all use these addresses.

What it does

terraform state list reads the current state and outputs one resource address per line (e.g. aws_instance.web, module.db.aws_db_instance.this). You can filter by a partial address or a resource type to narrow the output.

Common usage

Terminal
# List all resources in state
terraform state list

# Filter to a module or a type
terraform state list module.network
terraform state list aws_instance.web

# Match a specific indexed instance
terraform state list 'aws_instance.web[0]'

Common error in CI: cannot read remote state

state list fails with "Error: Failed to load state: AccessDenied" or "Error: Backend initialization required" when the job lacks backend credentials or has not run init. Fix: run terraform init with the correct backend config and ensure the CI role can read the state bucket/table (s3:GetObject, dynamodb:GetItem for an S3 backend). state commands need real backend access even though they do not touch providers.

Key options

OptionPurpose
[address]Filter results to a partial address
-state=FILEUse a specific local state file
-id=IDFilter by resource instance ID

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →