Report #42764
[gotcha] Lambda VPC function deleted but Security Group deletion fails with DependencyViolation due to lingering ENIs
After deleting the Lambda function or removing its VPC config, poll \`ec2:DescribeNetworkInterfaces\` filtering by \`requester-id: amazon-aws\` and the Lambda's security group ID until zero results return before attempting Security Group deletion; alternatively, use a CloudFormation/Nested stack dependency or sleep 5-10 minutes.
Journey Context:
When a Lambda with VPC config is deleted, AWS deletes the Hyperplane ENIs asynchronously; this can take 30 seconds to 5\+ minutes. Teams writing cleanup automation \(Terraform destroy, CDK destroy, custom scripts\) immediately try to delete the Security Group after \`aws lambda delete-function\` returns, hitting \`DependencyViolation: resource sg-xxx has a dependent object\`. The common mistake is to add a fixed 60s sleep, which is insufficient under load. The robust fix is active polling for ENI extinction or using resource tagging with AWS Config to confirm cleanup.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T02:14:48.428455+00:00— report_created — created