I did the AWS misfits tutorial and I thought the cleanup would be as simple as deleting the Cloud Formation stack. However, items failed to delete so I am trying to clean them up manually to assist the Cloud Formation stack deletion.
I keep getting an error when trying to Detach the network interfaces (I am logged into the root account):
Error detaching network interfaces:
eni-0047gfhfgh8ab0e: You are not allowed to manage 'ela-attach' attachments. eni-0f4a46hgfha757e: You are not allowed to manage 'ela-attach' attachments.
I am unable to delete my VPC without these being deleted.
The stack as a whole is failing to delete because of the following: The following resource(s) failed to delete: [InternetGateway, PublicSubnetTwo, VPC, GatewayAttachement, PublicSubnetOne].
You cannot detach a primary network interface from an instance. You can create and attach additional network interfaces. The maximum number of network interfaces that you can use varies by instance type. For more information, see IP addresses per network interface per instance type.
In the navigation pane, under Network Interfaces, search for the VPC ID of the Amazon VPC that you're deleting. Select the network interface and choose the Details tab. Review the Description to see which resources the network interface is attached to. Delete the associated resources.
I had the same issue, which gave me the following message:
This could be because there is a service in use which still uses the network interface. You could try some of the following things:
If that doesn't help, there is something wrong/stuck on the underlying OS, you should wait for it to resolve by itself or report it. I had an ENI deployed by a Lambda function after deleting the lambda function, the ENI got stuck. After some time I was able to detach the ENI.
AWS offers this bash script as help to find out the dependencies:
#!/bin/bash vpc="vpc-xxxxxxxxxxxxx" aws ec2 describe-internet-gateways --filters 'Name=attachment.vpc-id,Values='$vpc | grep InternetGatewayId aws ec2 describe-subnets --filters 'Name=vpc-id,Values='$vpc | grep SubnetId aws ec2 describe-route-tables --filters 'Name=vpc-id,Values='$vpc | grep RouteTableId aws ec2 describe-network-acls --filters 'Name=vpc-id,Values='$vpc | grep NetworkAclId aws ec2 describe-vpc-peering-connections --filters 'Name=requester-vpc-info.vpc-id,Values='$vpc | grep VpcPeeringConnectionId aws ec2 describe-vpc-endpoints --filters 'Name=vpc-id,Values='$vpc | grep VpcEndpointId aws ec2 describe-nat-gateways --filter 'Name=vpc-id,Values='$vpc | grep NatGatewayId aws ec2 describe-security-groups --filters 'Name=vpc-id,Values='$vpc | grep GroupId aws ec2 describe-instances --filters 'Name=vpc-id,Values='$vpc | grep InstanceId aws ec2 describe-vpn-connections --filters 'Name=vpc-id,Values='$vpc | grep VpnConnectionId aws ec2 describe-vpn-gateways --filters 'Name=attachment.vpc-id,Values='$vpc | grep VpnGatewayId aws ec2 describe-network-interfaces --filters 'Name=vpc-id,Values='$vpc | grep NetworkInterfaceId
My issue was a Transit Gateway Attachment and I could figure it out at some point.
Source: https://aws.amazon.com/premiumsupport/knowledge-center/troubleshoot-dependency-error-delete-vpc/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With