State and Apply Recovery Playbooks

Scenario: The terminal disconnects midway through apply and nobody knows whether remote resources were created.

Do not immediately rerun or edit state. Determine whether the process or remote run continues, inspect backend lock and run status, query provider objects, then run a fresh plan after concurrency is resolved. Terraform applies graph operations incrementally and records successful changes when possible; partial failure is recoverable when identity remains accurate. Import missing mappings or remove incorrect ones only after evidence.

Analogy: After a power cut during a warehouse move, inventory both buildings before sending the movers again.

A worked configuration

terraform state list
terraform state show fakecloud_server.api
terraform plan
# use import/state operations only for a proven mapping problem

Maintain backend backups, stale-lock procedures, provider rate-limit guidance, and escalation contacts. Recovery speed comes from calm observation and known playbooks, not force flags.

Note: Treat the plan as a change contract: understand every create, update, replacement, and destroy before approving it.
Goal: Reinforce this lesson in the tf-remote-state-locking Terraform lab. Open /labs/terraform and choose slug tf-remote-state-locking; the lab runs real Terraform against the offline FakeCloud provider.