Can't delete AWS internet Gateway

Amazon Web-ServicesNetworkingAmazon Ec2Amazon VpcGateway

Amazon Web-Services Problem Overview


I created an internet gateway in AWS VPC dashboard, I attached it to a VPC then I want to detach it but I keep getting this error:

Network vpc-xxxx has some mapped public adresses, Please unmap those public addresses before detaching the gateway. ( Service: AmazonEC2; Status Code: 400; Error Code: DependencyViolation; Request ID: qfdqsdf)

What to do to detache this IGW ? Why exactly do I get this error?

I need to get rid of this IGW without deleting extra resources. please any ideas?

For information, the route table of the VPC does contain public addresses but they are routed to other targets. This IGW is not set as target anywhere.

Amazon Web-Services Solutions


Solution 1 - Amazon Web-Services

You have some resources in the VPC that have been assigned a Public IP address, such as:

  • Amazon EC2 instances
  • Amazon RDS instances
  • Amazon Redshift cluster
  • VPC NAT Gateways
  • etc.

These IP addresses might have been assigned as an Elastic IP address or as an "auto-assign Public IP address" no instance creation.

You will need to delete these Elastic IP addresses before the Internet Gateway can be removed. If they were auto-assigned IP addresses, then Stop the instances to remove the public IP addresses.

You might also need to edit your Route Tables so that they do not refer to the Internet Gateway.

Solution 2 - Amazon Web-Services

had eks in a vpc, deleted the cluster but now there's network interfaces with an EIP and sg attached to them that were loadbalancers that did not get deleted when deleting the cluster because the deployments were not deleted inside the cluster before deleting the cluster itself. Had to find all associated ELB's and delete them, then security groups, then intefaces, EIP, all the way down the line till finally deleting the internet gateway and vpc.

Solution 3 - Amazon Web-Services

I had to delete NAT gateway that was hanging around to resolve mine.

Solution 4 - Amazon Web-Services

For those facing the same problem check also Route tables having the Internet Gateway as target

Solution 5 - Amazon Web-Services

Personally, I had to manually reject connections from the endpoint services in the VPC.
Endpoint Services > Select Service > Endpoint Connections > Select connection > Actions > Reject endpoint connection request

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSouadView Question on Stackoverflow
Solution 1 - Amazon Web-ServicesJohn RotensteinView Answer on Stackoverflow
Solution 2 - Amazon Web-ServicesBen AView Answer on Stackoverflow
Solution 3 - Amazon Web-ServicessimplytundeView Answer on Stackoverflow
Solution 4 - Amazon Web-ServicessmndiayeView Answer on Stackoverflow
Solution 5 - Amazon Web-ServicesKaruhangaView Answer on Stackoverflow