FG
☁️ Cloud & DevOpsAmazoncloud

Terraform apply hangs indefinitely on AWS VPC deletion

Fresh23 days ago
Mar 14, 20260 views
Confidence Score69%
69%

Problem

terraform apply hangs forever when trying to destroy an AWS VPC that has dependent resources (security groups, subnets, internet gateways) not managed by the current Terraform state. The AWS API never returns an error — it just waits. The operation must be killed manually. The fix requires identifying and deleting the unmanaged dependent resources first.

Error Output

aws_vpc.main: Still destroying... [id=vpc-0abc1234, 10m elapsed]
aws_vpc.main: Still destroying... [id=vpc-0abc1234, 20m elapsed]

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Moderate Confidence Fix
66% confidence64% success rate6 verificationsLast verified Mar 14, 2026

Delete unmanaged dependent resources before terraform destroy

High Risk

AWS requires all dependent resources in a VPC (security groups, ENIs, subnets, IGW) to be deleted before the VPC can be deleted. Resources created outside Terraform are not tracked in state and block deletion indefinitely.

66

Trust Score

6 verifications

64% success
  1. 1

    Kill the hanging terraform apply

    Press Ctrl+C to cancel. Note the VPC ID from the error output.

  2. 2

    Find all resources in the VPC

    List all ENIs, security groups, and subnets in the VPC:

    bash
    aws ec2 describe-network-interfaces --filters "Name=vpc-id,Values=vpc-XXXX" --query 'NetworkInterfaces[*].NetworkInterfaceId'
    aws ec2 describe-security-groups --filters "Name=vpc-id,Values=vpc-XXXX" --query 'SecurityGroups[?GroupName!=`default`].GroupId'
  3. 3

    Delete the unmanaged resources

    Delete each resource that Terraform does not manage. Then re-run terraform destroy.

Validation

terraform destroy completes without hanging. VPC is deleted.

Verification Summary

Worked: 6
Partial: 1
Failed: 4
Last verified Mar 14, 2026

Sign in to verify this fix