terraform state list Command Reference
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 current state and outputs one resource address per line (for example aws_instance.web, module.db.aws_db_instance.this). You can filter by a partial address or a resource type.
Common flags and usage
- [address]: filter results to a partial address or type
- -state=FILE: use a specific local state file
- -id=ID: filter by resource instance ID
- Quote bracketed addresses like 'aws_instance.web[0]' so the shell does not glob them
Example
shell
# Confirm an address before a state move or import
terraform state list module.network
terraform state list 'aws_instance.web[0]'In CI
state commands need real backend access, so run terraform init with the correct backend config and ensure the CI role can read the state store. Use state list to copy exact addresses before mv, rm, or import.
Key takeaways
- state list prints one tracked resource address per line.
- It needs backend credentials even though it never calls providers.
- Filter and quote addresses to copy exact targets for mv, rm, and import.
Related guides
terraform show Command ReferenceReference for terraform show in CI/CD: render a saved plan or state as human-readable or JSON for policy chec…
terraform import Command ReferenceReference for terraform import in CI/CD: bring existing infrastructure under management, use the declarative…
terraform force-unlock Command ReferenceReference for terraform force-unlock in CI/CD: clear a stale state lock left by a crashed run, with the safet…