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
# 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
| Option | Purpose |
|---|---|
| [address] | Filter results to a partial address |
| -state=FILE | Use a specific local state file |
| -id=ID | Filter by resource instance ID |