Interview Prep/Terraform/Import Refactoring Drift and Lifecycle

A resource was deleted from the console. What does Terraform do on the next plan?

BeginnerScenarioImport Refactoring Drift and Lifecycle
Answer

Situation read → State says it exists, the cloud says it doesn't.

What I'd do →

  1. Run terraform plan; refresh notices it's gone and plans to create it again.
  2. If the deletion was intended, remove the code too.
  3. Otherwise apply to recreate.

Why → Terraform drives toward the code; missing means "create".

Interview tip → For data-bearing resources recreation does not restore data; use backups.

All Terraform questions Roadmap: Terraform in production

More on Import Refactoring Drift and Lifecycle