Adding An Elastic IP To An Amazon Linux EC2 Instance
Contents
In this post I’ll assign an Elastic IP to my Exam_CSAA_Maarek_3 EC2 instance. I stopped the instance last time to reduce charges:
Note there is no Public IP listed. Starting the instance allocates a new IP address:
And while rebooting the instance doesn’t change this, stopping and starting it again attaches another completely different IP:
Depending on what the instance is being used for this could cause issues. To combat this, AWS allow Elastic IPs to be assigned to instances. This is available on the EC2 dashboard under Network & Security > Elastic IPs
. After choosing to allocate an address from Amazon’s pool I am presented with my new Elastic IP:
I’ll now associate the Elastic IP with my instance. I right-click on the IP and choose Associate Address, then choose the EC2 instance from the list presented:
The Elastic IP dashboard then updates with the EC2 instance’s ID:
And on the EC2 dashboard the IP address has changed again, this time to match the Elastic IP:
The instance can now be stopped and stared as often as needed - the IP will stay the same.
My final actions will be disassociating the Elastic IP address from the instance via the Networking options available from right-clicking on the instance, and then releasing the Elastic IP address itself back to Amazon. This is to prevent unnecessary charges - at time of writing, Elastic IP address doesn’t incur charges as long as the following conditions are true:
- The Elastic IP address is associated with an EC2 instance
- The instance associated with the Elastic IP address is running
- The instance has only one Elastic IP address attached to it
AWS charge by the hour for each Elastic IP address that doesn’t meet these conditions.
Thanks for reading ~~^~~
Author Damien Jones
LastMod 2019-10-30