Inspect and manipulate Terraform state directly.
high risk
terraform state pull > backup-$(date +%s).tfstateBack up the state before any edit.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.
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 →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.
Reference text is hand-written and may be incomplete — check man terraform for your version. Test destructive commands on a non-production system first.