Reconcile reality after an interrupted change
What This Concept Is
Recovery reconciles desired configuration, recorded bindings and observed resources. Restoring an older state snapshot changes Terraform's record; it does not reverse successful provider operations. State recovery and infrastructure rollback therefore require separate reasoning.
Why It Matters Here
The original drift/import and module-upgrade labs can look correct on a clean happy path. An interruption makes the distinction important: a resource can exist even when the last recorded snapshot does not contain its binding. Blind retry or replay of old state can propose duplicate creation, unintended replacement or loss of management.
Concrete Example
A change creates a synthetic resource R, then the state write fails. The previous snapshot lacks R. A recovery operator preserves logs and verifies R's identity and configuration. They then choose a documented reconciliation/import path and review the resulting plan, rather than declaring R nonexistent because the old state omits it. A different case—an address rename with the same underlying resource—calls for address migration, not an engine upgrade or arbitrary replacement.
Common Confusion / Misconception
Import records a relationship to an existing object; it does not guarantee the configuration now matches it. A moved block preserves an address relationship; it does not make an incompatible resource attribute update nondestructive. A clean plan is evidence only for the configuration, inputs, provider observations and scope used in that run.
How To Use It
Stop competing writers. Preserve the last known state, run logs and observed object IDs under appropriate access controls. Build a reconciliation list: desired address, recorded ID, observed object, evidence confidence and proposed repair. Distinguish unknown observations from absent resources. After an approved repair, review a new plan and check the application behavior. Keep identity continuity evidence for upgrades.
Check Yourself
Which changes does restoring a state file undo? What if the provider query failed? Does a clean refresh-only plan prove configuration agreement? When is a moved block relevant, and when is it irrelevant?
Mini Drill or Application
Write an interruption packet with one successful external action and a missing state write. Add a second packet with an inaccessible resource query. Explain why the second cannot be called absent. In the original module-upgrade exercise, retain before/after addresses and IDs and show no unintended replacement using actual plan evidence when the tool is available.
Read This Only If Stuck
Terraform state backends explains state-write recovery and protections. Terraform plan modes distinguishes ordinary and refresh-only planning.
Pro Git supports versioned change and review discipline; the linked HashiCorp documentation governs Terraform behavior.