DEV Community

Cover image for How to Add an Elastic (Static) IP to Your EC2 Instance And Update Your DNS Records on Route53

How to Add an Elastic (Static) IP to Your EC2 Instance And Update Your DNS Records on Route53

Assigning an Elastic IP to Your EC2 Instance

Once your EC2 instance is up and running, the next step is to assign an Elastic IP address to it. This ensures your instance has a static public IP, which remains consistent even if the instance is stopped and started. This is crucial for maintaining a reliable connection to your application or website.


What is an Elastic IP?

An Elastic IP is a static IPv4 address designed for dynamic cloud computing. It allows you to associate a persistent IP address with your EC2 instance, enabling seamless connectivity without worrying about changing IP addresses.


Benefits of Using an Elastic IP:

  1. Static Public IP: Provides a fixed IP that won’t change, making it easy to set DNS records.
  2. High Availability: You can quickly remap the Elastic IP to another instance if needed, ensuring minimal downtime.
  3. Cost-Effective: It's free as long as it’s associated with a running instance.

Steps to Add an Elastic IP to Your EC2 Instance:

Allocate an Elastic IP

  1. Go to the EC2 Dashboard in the AWS Management Console.
  2. In the left-hand menu, select Elastic IPs.
  3. Click on Allocate Elastic IP address.
  4. Select Amazon's pool of IPv4 addresses.

Associate the Elastic IP with Your Instance

  1. Click Allocate.
  2. Click Associate this Elastic IP address.
  3. Choose Your Instance from the dropdown.
  4. Optionally, specify a private IP address if your instance has multiple private IPs.
  5. Click Associate

Update Your DNS Records

Once the Elastic IP is associated, update your DNS records in Route 53 to point your domain to the new Elastic IP.

  1. Go to the Route 53 dashboard.
  2. Select your hosted zone.
  3. Edit or create an A record to use the Elastic IP.

Verification:

To confirm everything is working:

  1. Open a browser and type your domain name.
  2. You should see your application or website resolving correctly.

Now that your EC2 instance has a static public IP, your application is better equipped for reliable and consistent access, and you can stop your instance, update your user data without losing your IP!

Check out: Student Analyst to observe the steps in this series.

Top comments (0)