EC2 instance doesn't get a new public IP after Elastic IP is disassociated
I recently had a need to attach an Elastic IP to an instance that previously had a Public IP - got tired of changing SSH keys whenever I rebooted as I was assigning the same private IP to the instance. However, the need for a static IP across reboots has now waned and I wanted to revert to the Public IP setting. However, after detaching the Elastic IP, the instance did not get another Public IP as stated in this document:
Instead, I had to resort to creating an AMI and launching a new instance with a Public IP. Is this now the only way to get a Public IP after an Elastic IP is detached?
The reason why you can't get the public IP address when you detach the EIP you asked for the first time is also because the secondary ENI is attached.
And we will advise you on your additional questions.
I understand that you are attaching and detaching Elastic IP between nodes to achieve floating IP.
You can build a Network load Balancer for inbound and outbound to communicate by installing a NAT gateway in each AZ from the private subnet.
Or, if you just want to operate the AWS CLI while keeping the current configuration, how about using the VPC endpoint to operate the Elastic IP with private communication?
Thanks @iwasa. I'm new to load balancers on AWS so I'm going to have to go read about them before I proceed. Need to get a full understanding before I start migration of production workloads.
I'll post back once my understanding is clear; will most likely accept this as the answer.
Detaching an Elastic IP address usually assigns it a public IP address.
Isn't it assigned even if stop → start?
In that case, you may have multiple ENIs attached to your EC2. In that case, the public IP address will not be automatically assigned when the Elastic IP address is detached.
If the public IP address of your instance in a VPC has been released, it will not receive a new one if there is more than one network interface attached to your instance.
You should detach the non-primary ENI once, stop EC2 and then start. You should be assigned a public IP address.
Then reattach the detached secondary ENI.
In general though If you require a persistent public IP address that can be associated to and from instances as you require, use an Elastic IP address instead of Public IP.
Thanks for all your answers and I see I'm in a bit of a quandary.
I'm in the process of setting up a highly available NFS cluster using BRDB across AZ's and hence need secondary interfaces as well as Elastic IP's. I was intending on making use of the OCF Heartbeat RA's - namely awseip and awsvip. The problem occurs when the floating IP is moved to another node. When that happens, the node can no longer reach the AWS API via AWSCLI since there's no longer an IP address that can reach the Internet. Currently, I'm forced to do it all in the same node AZ but that means if the AZ is down, then so too is that "highly (un)available" NFS cluster.
Out of the box thinking will be required here.
Can't ssh to EC2 after assigning an additional public ip(elastic ip)AWS-User-3791798asked 5 months ago
Do Elastic Beanstalk Web Server Environment Need A Public Elastic IPBansheebombasked 2 days ago
EC2 instance doesn't get a new public IP after Elastic IP is disassociatedak2766asked 4 days ago
EC2 Instance No Response after Force StopAWS-User-2646245asked 3 months ago
Ec2 Not connecting to InternetAccepted AnswerHimanshuasked a month ago
Verify foreign Elastic IPAccepted Answerfranksonasked 2 months ago
ec2 won't respond after stoppingAccepted AnswerJoziPasked a year ago
EC2 Instance IP keeps changing despite elastic IPAWS-User-4407694asked 3 months ago
Static IP address for EC2 Instanceses2asked 2 years ago
Charge for 77hs for attached elastic ipKevinH89asked 3 years ago