Interview Prep/Terraform/Import Refactoring Drift and Lifecycle

How do you test a refactor so that you're sure nothing will be destroyed?

IntermediateScenarioImport Refactoring Drift and Lifecycle
Answer

Situation read → A refactor should have a no-op plan.

What I'd do →

  1. Run terraform plan -out=refactor.tfplan against a copy of production state or a staging replica.
  2. Inspect with terraform show -json refactor.tfplan | jq '.resource_changes[] | select(.change.actions != ["no-op"]) | .address'.
  3. Gate the PR on that command printing only intended moves.

Why → The plan is machine-readable truth about what will change.

Interview tip → Moves show as no-op with previous_address set.

All Terraform questions Roadmap: Terraform in production

More on Import Refactoring Drift and Lifecycle