terraform state

Inspect and manipulate Terraform state directly.

high risk

interactive breakdown — edit the command and press Explain
$ 
⚠ Risks & cautions
Safer / dry-run alternatives
terraform state pull > backup-$(date +%s).tfstateBack up the state before any edit.
What it does

terraform state commands allow direct inspection and manipulation of the state file without modifying infrastructure. Essential for recovering from drift, importing existing resources, renaming resources, and resolving state conflicts.

Examples
terraform state listList all resources tracked in state · explain & risk-check →
terraform state show aws_instance.webShow detailed state for a specific resource · explain & risk-check →
terraform state mv aws_instance.old aws_instance.newRename a resource in state (after refactoring HCL) · explain & risk-check →
terraform state rm aws_instance.webRemove resource from state (stop managing, don't delete) · explain & risk-check →
terraform import aws_instance.web i-0abc123def456Import existing AWS resource into state · explain & risk-check →
Pro tip

Use `terraform state rm resource.name` to untrack a resource you want to keep but manage outside Terraform — safer than deleting the HCL config directly.

Related
terraform plan terraform apply jq
Open the full explainer →More in Terraform, Ansible & IaC

Reference text is hand-written and may be incomplete — check man terraform for your version. Test destructive commands on a non-production system first.