Tuesday 3 July 2018

AWS - Public IP vs Elastic IP

When you launch an EC2 instance, you recieve a Public IP address by which that instance is reachable.
Once you stop that instance and restart the you get a new Public IP for the same instance's.

So, Public IP get's changed everytime for an instance after stop/start.

To overcome with this problem, we attach an Elastic IP to an Instance which doesn't change after you stop / start the instance as many times.

Advantage of Having Elastic IP
-> It is kind of static IP for your Instance.
-> Doesn't change after stop/start.

If you have Elastic IP in your account and  it's not in use, then you will be charged for it.

==================================================

The advantage of an Elastic IP (EIP) is that you can move an IP address from one host to another. This can help you to build a more resilient system.

Let's say your host is at 1.2.3.4 and that host becomes unhealthy. You can then start up a new, equivalent host and move 1.2.3.4 from the bad host to the good host. No DNS changes would be required, which is a win considering that many clients do not respect DNS TTL and would otherwise continue to try to talk to the old host. This is a simple (but fairly blunt) way to provide failover. You can also use it when upgrading a host, in which case you would run the new host side-by-side with the old, validate the new host, and then move the EIP to the new host.

PS some EC2 instances come with a public IP, not all EC2 instances. If you are launching into VPC and you do not request a public IP then the instance does not get one. This is how you build a private subnet.