Setting up an EC2 instance and assigning an Elastic IP address

In this mini tutorial , I am going to walk you through the straightforward process of assigning an Elastic IP and associating it with your EC2 instance.
After you create a new EC2 instance, you can select Elastic IPs menu from the Network & Security section on the left side.

Goal :  Create an independent IP address that can be reachable externally .

Problem: Lets see the problem we are trying to solve.  When you create an EC2 instance, it will be allocated a private IP and a public IP.   The private IP is local to your VPC and is used internally.  The public IP is reachable from the internet, however , if you stop and start the EC2 instance, the public IP changes.  Now if the public IP keeps changing every time you stop and start , you will have to keep making DNS changes repeatedly which we want to avoid.

Solution: We can create an Elastic IP address.  This is allocated to your account and remains active till you delete it.  We associate or disassociate this IP address to any EC2 instance.  So this is a more flexible approach to manage and expose the public IP externally. However you have to be careful regarding the charges, as any Elastic IPs that are not associated to EC2 instances are charged .