← Terraform: plan changes and operate infrastructure
06 / 6 · 40 MIN

Adoption and recovery

Adopt existing resources and recover partial changes using actual state.

Concept and mechanism

Importing binds an existing object to a managed instance; it does not mean any subsequently written configuration matches the object. In a declarative workflow, identify the object and destination address, confirm provider support, and prepare the corresponding resource. Review the plan before accepting changes accompanying adoption. Keep one management responsibility per object to avoid two configurations managing the same resource inconsistently. During incidents, a manual change may be necessary but leaves a later decision: incorporate it into configuration or restore intended state. Refresh-only updates the record to reflect observations; it neither rewrites code nor automatically repairs infrastructure.

Guided application

In a fictional exercise, apply created a network and failed on an access policy. The error does not guarantee reversal of what was already created. Preserve evidence, inspect state and actual resources, fix the cause, and review the new plan before continuing. Do not simply replace state with an earlier copy because that can lose bindings to existing resources. Use target only for justified exceptional situations and return to evaluating the full scope. If resource responsibility transfers to another team, a removed block with destroy=false can stop management without destroying the object; do not assume a safe default. Confirm the new owner, dependencies, costs, and data protection before completing handover.

IN PRACTICE

Apply failed after network creation: reconcile the existing network rather than assume it was never created.

Common pitfalls

Import as correct configuration; refresh-only as updated code; old state as physical rollback.

Related topics: Configuration and dependencies · Plans and validation · State and collaboration

Take this idea with you

Reconcile objects, configuration, and responsibilities before the next operation.

Create account

Reference: Saved plans and partial apply errors · Terraform v1.16 concepts; official documentation consulted 2026-09-30; provider and backend capabilities must be confirmed