VPC Delete Troubles

0

Hello!

I have followed all of the directions, used all the scripting hacks I can find and I still cannot delete this stupid VPC. It says it was created for some SAM application example I did a while back but I swear I can't find the original EC2 resources it says belong to it.

Who do I call and how much do I have to pay to terminate this "vpc-c92108b1" ???

Thank you!

JB
asked 3 years ago306 views
6 Answers
0

Hi JB

Thank you for reaching out :)

All the resources attached to the VPC have to be terminated or released first. There could be an internet gateway, NAT gateway, security group, route table, associated subnets, associated elastic IP or network ACLs that are causing this. Make sure that there is no network interface attached to your VPC as well.

Did you run the following script:

#!/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

You can find this script in the below link:
https://aws.amazon.com/premiumsupport/knowledge-center/troubleshoot-dependency-error-delete-vpc/

If you run into any trouble feel free to create a case to our billing team which can help locate the resources and help with any billing related questions that you might have.

  1. Open AWS Knowledge Center at https://aws.amazon.com/premiumsupport/knowledge-center/
  2. Choose Billing Management.
  3. Scan the list of topics to locate a question that is similar to yours.

I hope this helps!

naz97
answered 3 years ago
0

So I did run that script and I tried to delete those resources but every single one said it had some dependency that prohibited its deletion.

What would be helpful is a script that would list in order what needed to be deleted so you could just go down the list logically and delete this stupid thing.

Thanks for your reply though. I will also delete these roles. That is the one thing I did not attempt to delete. But the network adapter is the first one it complains about. I try to delete that and it complains that it is still in use.

Frustrating!

JB
answered 3 years ago
0

I am starting to find that SageMaker is also involved. It is saying a SageMaker instance is in use and I cannot delete the user "thing" for the SageMaker. Says the "Resource is in use."

ResourceInUse
The ID or Name specified is already in use.

Edited by: JB on May 18, 2021 9:53 AM

JB
answered 3 years ago
0

I am logged in as the owner/root of this account and I get this;

[cloudshell-user@ip-10-1-174-185 scripts]$ aws ec2 detach-network-interface --attachment-id ela-attach-e3036cee

An error occurred (OperationNotPermitted) when calling the DetachNetworkInterface operation: You are not allowed to manage 'ela-attach' attachments.

JB
answered 3 years ago
0

I am logged in as the owner/root of this account and I get this;

[cloudshell-user@ip-xxx5 scripts]$ aws ec2 detach-network-interface --attachment-id ela-attach-e3036cee

An error occurred (OperationNotPermitted) when calling the DetachNetworkInterface operation: You are not allowed to manage 'ela-attach' attachments.

Edited by: JB on May 18, 2021 11:43 AM

JB
answered 3 years ago
0

Turns out, there was an EFS volume that was associated with the Network Interface! The scripts everyone provided never considered the fact an EFS volume could hold a Network Interface open as "In Use."

The only way I figured it out was in the description of a subnet saying it was created for an EFS

JB
answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions