Home›Guides›state rm vs removed block

Stop managing a resource without destroying it: state rm or removed block

Sometimes a resource should stay in the cloud but leave your code — handed to another team, or managed elsewhere. Deleting the resource block would destroy it. There are two safe ways out.

Option 1: tofu state rm

tofu state rm -dry-run module.foo.aws_instance.worker
tofu state rm module.foo.aws_instance.worker

Removes the binding from state; the real object keeps running. -dry-run lists what would be removed. Addresses can target a resource, a module, or a single count / for_each instance.

Catch: if the resource block is still in your code, the next plan proposes to create a new object — which may fail on name conflicts. Remove the block from code too.

Option 2: the removed block (OpenTofu 1.7+)

removed {
  from = aws_instance.worker

  lifecycle {
    destroy = false
  }
}

Declares in code that the resource should be forgotten, and destroy = false keeps the object running. It goes through review and a plan like any other change.

Which one?

Examples use OpenTofu (tofu); in Terraform the commands start with terraform. Check the documentation for your version before relying on a feature.

Splitting a large state?We do this as a fixed-price job.IaC Health Check →

Book a 30-minute call

Tell us what you are trying to fix. No preparation needed.

Book a 30-minute call