Interview Prep/Terraform/State Backends and Workspaces

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 →

  1. state rm and removed { destroy = false }: forget the resource; the real one stays.
  2. Deleting the resource block normally: destroys the real one on next apply.
  3. 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.

All Terraform questions Roadmap: Terraform in production

More on State Backends and Workspaces