What is the difference between `terraform state rm`, `removed` and `terraform destroy -target` for getting a resource out of your config?
BeginnerScenarioState Backends and Workspaces
Answer
Situation read → Three tools with very different outcomes.
What I'd do →
state rmandremoved { destroy = false }: forget the resource; the real one stays.- Deleting the resource block normally: destroys the real one on next apply.
destroy -target: destroys now, outside normal flow; use only in recovery.
Why → Pick by intent: forget, delete via code, or emergency delete.
Interview tip → Prefer the code-based options so there's a commit trail.
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