Background:Amazon EC2 instance assigned with a public and private ip address. The public ip address changes when the instance stopped and started again but not when the instance restarted. Due to this nature service is prone to interruption if the instance stopped for maintenance and started again.
Workaround:Amazon offers the Elastic IP for instances which will not change in the above scenario and helps ensure the configurations of your servers and services you are providing. To enable and assign Elastic IP to an instance go through the following.
- Go to the Elastic IPs under Network & Security section. Select Allocate New Address from top.
- Allocate New Address window will open, select Allocate.
- Showing you the message of successful allocation of Elastic IP.
- Now choose the Elastic IP allocated just now. From top select Actions > Associate address.
- Now select the instance from the drop down list and click the Associate button.
- Successful association will shown to you.
- Go to the Instances, select the instance and see the Elastic IP and the IPV4 Public IP has changed and are same. Also the Public DNS changed accordingly.
- You are done!