Elastic IP is a public static IP that is associated with your AWS account. You can associate it to any EC2 instance within the same region as your Elastic IP. If you have an EC2 instance that should be accessible from the internet, it should either have a public IP or an Elastic IP associated to it.
If you are using public IP with an EC2 instance, the IP address is released everytime the instance is shutdown. A new IP address will be assigned to the EC2 instance once it is started back. Thus, the connection details are not static with a public IP. Elastic IP being static solves this issue.
Login to AWS management console and choose EC2 service. In the EC2 dashboard, select Elastic IPs under NETWORK & SECURITY and choose Allocate new address.
AWS will allocate you an IP address from the pool of available IP addresses. Choose Allocate.
You will see the message as below if the IP address allocation is successful. Click on Close. You can associate this IP address to any EC2 instance within your AWS account.
Right click on the newly allocated IP address and choose Associate address.
Leave the Resource type as Instance and select the Instance ID that you would like to associate the IP address to and choose Associate.
You will see the below success message after IP address is associated.
Note that the previously associated public address has been released and the elastic IP is now associated to the EC2 Instance.
You can disassociate the IP address from the EC2 instance and associate it to another EC2 instance if you wish so. To disassociate the IP address, right click on the Elastic IP address and choose Disassociate address.
The IP address will then be disassociated from the EC2 instance and it will be available to be associated to any EC2 instance within the region. Amazon charges for Elastic IP addresses that are allocated to an AWS account and not being used. They do not charge for the Elastic IP addresses that are in use.