How to Assign An Elastic IP To an EC2 Instance On AWS
An elastic IP is a static IP address that is used with EC2 instances. Instead of getting a public DNS name like ec2-xxx-34-xxx-49.eu-west-1.compute.amazonaws.com which changes every time you restart the instance, you can assign your EC2 instance an elastic IP and it will never change unless you direct it to. Elastic IPs work in the following way:
In the AWS Console you go to EC2:
Then navigate to Network And Security and select Elastic IPs:
You then have to Allocate an IP to your account by hitting “Allocate New Address”
This brings up the following dialogue box where you assign the elastic IP to either standard EC2 or to your VPC depending on you use case:
Once the IP is assigned to your account you have the ability to “Associate Address” or “Disassociate Address” with an instance, you also have the ability to “Release Address” if you are no longer using it.
In our case we want to associate the address so we click the corresponding button and have the option to choose which instance it will be attached to.
Finally the IP is associated with our instance and can be accessed through the IP address. It is a good idea to release elastic IPs when not in use because you are charged when they are assigned to your account.