DependencyViolation: resource has dependent objects (destroy) Terraform Origin: Platform & cloud OSI layer 7 · Application Last updated 5 Nov 2026

Terraform: Error: deleting EC2 VPC (vpc-0abc): DependencyViolation: The vpc 'vpc-0abc' has dependencies and cannot be deleted

Destroy failed because something else still uses the resource (ENIs, subnets, gateways, security group rules).

Exact message you may see Error: deleting EC2 VPC (vpc-0abc): DependencyViolation: The vpc 'vpc-0abc' has dependencies and cannot be deletedDependencyViolation: resource sg-0abc has a dependent objectError: deleting Security Group: DependencyViolationError: error deleting subnet: DependencyViolation: The subnet has dependencies and cannot be deletedError deleting: DependencyViolation
Seen on: Terraform AWS

Meaning

Find what's attached (network interfaces, load balancers, endpoints, Lambda ENIs, resources created outside Terraform). Remove/detach them first, or fix dependency ordering with depends_on. Lambda/EKS leave ENIs that take minutes to release — retry. Use console/CLI (aws ec2 describe-network-interfaces --filters Name=vpc-id,Values=...) to locate blockers.

Common causes

  • ENIs from Lambda/EKS/ELB still attached
  • Resources created manually in the VPC/subnet
  • Security group referenced by another SG
  • Missing dependency ordering
  • Eventual consistency delay

⚡ Quick fix

  1. List dependents with the CLI and delete them
  2. Retry destroy after a few minutes
  3. Add explicit depends_on or manage dependents in Terraform

Detailed fix by platform

AWS

  1. aws ec2 describe-network-interfaces --filters Name=vpc-id,Values=vpc-0abc --query 'NetworkInterfaces[].[NetworkInterfaceId,Description]'

How to diagnose

  1. Dependents — Which?
  2. Origin — Managed by TF?
  3. Retry — After delay?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):

BucketNotEmpty: bucket you tried to delete is not empty — Terraform: Error: deleting S3 Bucket (my-bucket): BucketNotEmpty: The bucket you tried to delete is not empty (Terraform)BucketNotEmpty: bucke…Error: Cycle (dependency cycle) — Terraform: Error: Cycle: aws_security_group.a, aws_security_group.b (Terraform)Error: Cycle (depende…Instance cannot be destroyed (lifecycle.prevent_destroy) — Terraform: Error: Instance cannot be destroyed — Resource aws_db_instance.prod has lifecycle.prevent_destroy set, but the plan calls for this resource to be destroyed (Terraform)Instance cannot be de…Invalid AWS Region — Terraform: Error: Invalid AWS Region: us-east-3 / Error: configuring Terraform AWS Provider: validating provider credentials: operation error STS: GetCallerIdentity (Terraform)Invalid AWS RegionNo valid credential sources found (AWS provider) — Terraform: Error: No valid credential sources found — failed to refresh cached credentials, no EC2 IMDS role found / Error: configuring Terraform AWS Provider: no valid credential sources (Terraform)No valid credential s…timeout while waiting for state to become 'available' — Terraform: Error: waiting for RDS DB Instance create: timeout while waiting for state to become 'available' (last state: 'creating', timeout: 40m0s) (Terraform)timeout while waiting…UnauthorizedOperation / AccessDenied during Terraform apply — Terraform: Error: creating EC2 Instance: UnauthorizedOperation: You are not authorized to perform this operation. User: arn:aws:iam::123:user/ci is not authorized to perform: ec2:RunInstances (Terraform)UnauthorizedOperation…Dependenc…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.