Skip to content
Latchkey

Terraform "removed" Block Errors - Resource Still Declared in CI

A removed {} block (Terraform 1.7+) drops a resource from state without destroying the real object. It errors when the resource is still declared in config, or when the target address is wrong.

What this error means

plan fails on a removed block because the named resource is still present in the configuration, or the from address does not match anything Terraform tracks. The state removal does not proceed.

terraform output
Error: Removed resource still exists

  on removed.tf line 1:
   1: removed {

This statement declares a removal of aws_instance.legacy, but this resource
block is still present in the configuration. To remove a resource, its
configuration must be deleted.

Common causes

Resource block still in config

A removed block requires the resource block to be deleted from config. Keeping the block while adding removed is contradictory and rejected.

Wrong removed target address

The from address must match a resource Terraform currently tracks. A typo or wrong index makes the removal target nothing.

How to fix it

Delete the resource block, then declare the removal

Remove the resource block from config and add a removed block that forgets it without destroying the object.

removed.tf
# (the resource "aws_instance" "legacy" block is deleted)

removed {
  from = aws_instance.legacy
  lifecycle {
    destroy = false   # forget from state, keep the real resource
  }
}

Correct the target address

  1. Confirm the from address matches what terraform state list shows.
  2. Ensure the corresponding resource block has been deleted from config.
  3. Run terraform plan to confirm the removal (not a destroy) is planned.

How to prevent it

  • Delete the resource block in the same change that adds a removed block.
  • Match the from address to terraform state list output.
  • Use lifecycle { destroy = false } when you intend to keep the real object.

Frequently asked questions

What causes ""removed" block errors"?
A removed block requires the resource block to be deleted from config. Keeping the block while adding removed is contradictory and rejected.
How do I fix "removed" block errors?
Remove the resource block from config and add a removed block that forgets it without destroying the object.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card