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 →
- Use a
removedblock (Terraform 1.7+) withdestroy = false, then delete the resource block. - 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.
More on State Backends and Workspaces
Two engineers keep overwriting each other's changes because state is local. What's the fix?BeginnerSet up a production-grade S3 backend. What do you configure for locking?IntermediateHow do you harden the S3 bucket that holds Terraform state?IntermediateWho creates the state bucket itself, given Terraform needs it to exist before `init`?IntermediateA laptop apply and a CI apply start at the same time. What stops state corruption?IntermediateWhen are Terraform workspaces appropriate?Beginner