What is an Elastic IP address in AWS?

Elastic IP Address
Elastic IP Address

An Elastic IP (EIP) address in AWS is a static, public IPv4 address that you can allocate and assign to an EC2 instance. Unlike a regular public IP that changes when an instance is stopped and restarted, an Elastic IP remains constant, allowing you to maintain a fixed address for your applications.


Why Use an Elastic IP?

By default, AWS assigns a dynamic public IP to an EC2 instance when it is launched. However, this IP changes every time you stop and start the instance.

πŸ”Ή Problem: If for example your Application blog is hosted on an EC2 instance with a dynamic public IP, every time you restart the instance, the IP changes, causing disruptions.

πŸ”Ή Solution: An Elastic IP ensures that your Application site always has the same public IP, avoiding frequent DNS updates or reconfigurations.


Key Features of Elastic IPs

  1. Static & Persistent – Unlike normal public IPs, an Elastic IP doesn’t change when the instance is stopped or restarted.
  2. Reassignable – You can detach an Elastic IP from one instance and attach it to another without changing the IP.
  3. Charges Apply If Unused – AWS provides one free Elastic IP per account as long as it’s associated with a running instance. However, unused Elastic IPs incur charges.

How to Allocate and Associate an Elastic IP

Step 1: Allocate an Elastic IP

  1. Open the AWS Management Console.
  2. Navigate to EC2 Dashboard β†’ Elastic IPs (under Network & Security).
  3. Click on Allocate Elastic IP Address.
  4. Choose Amazon’s pool of IPv4 addresses and click Allocate.
  5. You will now have an Elastic IP allocated to your account.

Step 2: Associate the Elastic IP with an EC2 Instance

  1. Select the newly allocated Elastic IP.
  2. Click Actions β†’ Associate Elastic IP Address.
  3. Choose your EC2 instance from the list.
  4. Click Associate.

Now, your EC2 instance has a fixed, static public IP that will not change even if the instance is stopped and restarted.


Example Scenario: Hosting a Application with Elastic IP

Without Elastic IP

πŸ”Έ You launch an EC2 instance to host your Application.
πŸ”Έ AWS assigns a dynamic public IP (e.g., 54.200.120.50).
πŸ”Έ You map your domain (your-application.com) to this IP.
πŸ”Έ Later, you restart the instance, and AWS assigns a new public IP (e.g., 3.85.220.40).
πŸ”Έ Now, your website is inaccessible until you update the DNS settings with the new IP.

With Elastic IP

βœ… You allocate an Elastic IP (e.g., 18.220.50.80) and associate it with your EC2 instance.
βœ… You map your domain (your-application.com) to this Elastic IP.
βœ… Even if you restart the instance, the Elastic IP remains unchanged.
βœ… Your Application remains accessible without any DNS changes.


How to Release an Elastic IP (If No Longer Needed)

If you no longer need an Elastic IP, follow these steps to avoid unnecessary charges:

  1. Disassociate the Elastic IP from the instance.
    • Go to EC2 Dashboard β†’ Elastic IPs.
    • Select the Elastic IP and click Actions β†’ Disassociate.
  2. Release the Elastic IP back to AWS.
    • Select the Elastic IP and click Actions β†’ Release IP Address.

Once released, the IP is returned to AWS, and you will no longer be charged for it.


Elastic IP Best Practices

βœ… Use Elastic IPs only when necessary – If your EC2 instance is always running, using a DNS service like Route 53 with a domain name might be better than assigning an Elastic IP.

βœ… Avoid Unused Elastic IPs – AWS charges for unused Elastic IPs to discourage hoarding. Release any unneeded EIPs.

βœ… Consider Elastic Load Balancing (ELB) instead – If hosting a highly available Application site, an Elastic Load Balancer (ELB) distributes traffic across multiple instances without the need for a static IP.

βœ… Monitor Elastic IPs with AWS CloudWatch – Track IP changes, association, and costs using AWS CloudWatch for better management.


Final Thoughts

Elastic IPs provide a reliable, static public IP for your EC2 instances, ensuring that services like Application, APIs, and web applications remain accessible without frequent DNS updates. However, they should be used efficiently to avoid unnecessary costs.

Would you like help setting up an Elastic IP for your Application? πŸš€

About Anant 398 Articles
Senior technical writer