Interview Prep/Terraform/Import Refactoring Drift and Lifecycle

One change to a VPC output makes the plan replace 30 resources. How do you find out why, and reduce the damage?

AdvancedScenarioImport Refactoring Drift and Lifecycle
Answer

Situation read → A cascading replacement through dependencies.

What I'd do →

  1. Read the plan top-down: find the first resource marked forces replacement.
  2. Trace the attribute that forced it with terraform graph | dot -Tsvg.
  3. Revert or restructure: avoid changing immutable inputs, or use create_before_destroy.
  4. Do not apply until the root cause is understood.

Why → Replacing a parent (subnet, VPC, role) forces replacement of everything that has it as an immutable argument.

Interview tip → A blast-radius estimate in the PR description shows maturity.

All Terraform questions Roadmap: Terraform in production

More on Import Refactoring Drift and Lifecycle