Reputation: 4902
I have given a limited access to a AWS account.
I already created an EC2 instance but when I try to associate an elastic ip, I got the error below:
An error occurred while attempting to associate the address
Network vpc-(security id) is not attached to any internet gateway
Upvotes: 28
Views: 25472
Reputation: 868
Adding to the answer set here to add another case:
If you've been launching EKS clusters, EC2 may have configured the VPC that supports/supported your EKS cluster to be the default for the launch of new EC2 instances. This can be the case if you forgot to "clean up" and delete the VPC used for this purpose. EKS completes a lot of automatic actions behind the scenes, and one of those actions is to set up a new VPC.
If you've got an EKS VPC hanging around, it may be the default during the launching of new EC2 instances. Ensure you select the other VPC if you want to launch instances as you may have done prior to setting up EKS.
Ignore this answer if you haven't been setting up Kubernetes clusters through EKS on AWS!
Upvotes: 0
Reputation: 2694
You need to assign an Internet Gateway to your VPC.
Then you will be able to Assign the Elastic IP to your EC2 instance.
Upvotes: 2
Reputation: 531
This error occurs because the VPC is not associated with an Internet Gateway. To solve this: Go to VPC, then click on Internet Gateway. If none exists, Create one(probably will need admin permission) and then attach it to the target VPC-id. And try again associating the Elastic IP address to the EC2 instance. Hope it helps :)
Upvotes: 5
Reputation: 134066
You are using the new Amazon Virtual Private Cloud instead of the EC2 Classic. The cloud you are using lacks the internet gateway virtual component that is necessary for the cloud to be reachable from the public internet.
You need to add an internet gateway to your private cloud for it to be able to connect to internet; with that in place, you can use Elastic IPs (after all, they are internet addressable; your VPC instances can have static instance IPs), and add a routing entry for internet addresses (0.0.0.0/0, or a narrower space).
Upvotes: 33