Search code examples
amazon-web-servicesnetworkingamazon-ec2amazon-vpcgateway

Can't delete AWS internet Gateway


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.


Solution

  • 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" on 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.