Terraform Advanced — The removed Block

less than 1 minute read

Remove a resource from Terraform state without destroying the actual infrastructure.


The Problem

You want to stop managing a resource with Terraform
but NOT delete it from AWS.

If you just delete the resource block → terraform plan shows "will destroy"

The removed Block (Terraform 1.7+)

removed {
  from = aws_s3_bucket.legacy

  lifecycle {
    destroy = false   # Don't destroy the actual resource
  }
}
$ terraform apply
# Removes aws_s3_bucket.legacy from state
# Does NOT delete the S3 bucket from AWS

Before removed Block: terraform state rm

# Legacy approach (still works)
$ terraform state rm aws_s3_bucket.legacy
Removed aws_s3_bucket.legacy
Successfully removed 1 resource instance(s).

When to Use removed

  • Migrating a resource to a different Terraform stack
  • Handing off a resource to another team
  • Legacy resources you no longer want to manage
  • Splitting a monolithic state into smaller stacks

⚠️ Warning: After removed, Terraform no longer tracks the resource. Configuration drift won’t be detected.


What’s Next?

Practice import patterns.

← Bulk Import Strategies Practice Exercises →

Updated: