Interview Prep/Terraform/Import Refactoring Drift and Lifecycle

Resources are shared between two environments, such as a DNS zone. How do you avoid accidental deletion by either stack?

AdvancedScenarioImport Refactoring Drift and Lifecycle
Answer

Situation read → Shared dependency owned by neither environment.

What I'd do →

  1. Put shared resources in their own stack (foundation/dns) with its own state and owner.
  2. Environment stacks reference them with data sources.
  3. Add prevent_destroy and service-level deletion protection where available.

Why → Resources that outlive environments belong to a lifecycle of their own.

Interview tip → "Lifecycle boundaries define state boundaries."

All Terraform questions Roadmap: Terraform in production

More on Import Refactoring Drift and Lifecycle