Interview Prep/Terraform/State Backends and Workspaces

You want Terraform to stop managing a resource but leave it running.

BeginnerScenarioState Backends and Workspaces
Answer

Situation read → Handing off ownership.

What I'd do →

  1. Use a removed block (Terraform 1.7+) with destroy = false, then delete the resource block.
  2. Run terraform apply.
removed {
  from = aws_s3_bucket.legacy
  lifecycle {
    destroy = false
  }
}

Why → It's declarative and shows up in review, versus terraform state rm aws_s3_bucket.legacy which is an unreviewed manual edit.

Interview tip → Whichever you use, plan afterwards to confirm nothing will be destroyed.

All Terraform questions Roadmap: Terraform in production

More on State Backends and Workspaces