Interview Prep/Terraform/State Backends and Workspaces

Two repos accidentally manage the same S3 bucket. What happens, and how do you resolve it?

AdvancedScenarioState Backends and Workspaces
Answer

Situation read → Dual ownership: each state thinks it owns the resource, and they fight.

What I'd do →

  1. Decide the owner, ideally the team that owns the lifecycle.
  2. In the other repo, add a removed block with destroy = false (or state rm) and apply.
  3. Consumers of the bucket use a data source instead.
  4. Add CODEOWNERS or tagging (ManagedBy, Stack) to make ownership visible.

Why → Two states reconciling one resource produce perpetual diffs, and a destroy in either repo deletes it for both.

Interview tip → Ownership should be answerable from a tag.

All Terraform questions Roadmap: Terraform in production

More on State Backends and Workspaces