DEV Community

Cover image for πŸš€ AWS 121: Setting a Permanent Address - Launching EC2 with an Elastic IP
Hritik Raj
Hritik Raj

Posted on

πŸš€ AWS 121: Setting a Permanent Address - Launching EC2 with an Elastic IP

AWS

πŸ“ The Reliable Hub: Combining Compute with Static Networking

Hey Cloud Pioneers! πŸ‘‹

Welcome to Day 21 of the #100DaysOfCloud Challenge: Launch EC2 with Elastic IP! Today we are solving a classic problem for our Development Team at KodeKloud Engineer.

When you launch a standard EC2 instance, it gets a dynamic public IP. If the instance stops and starts, that IP changes, and the developers' connection breaks. Today, we are fixing that by associating a permanent Elastic IP (EIP) to our new server.

Our mission: Launch an Ubuntu-based t2.micro instance named devops-ec2 and link it to an Elastic IP named devops-eip.


1. Introduction: The Power of Persistence πŸ’‘

In AWS, standard public IPs are "borrowed" from a pool. An Elastic IP is "owned" by your account until you release it.

  • Instance Identity: The devops-ec2 will serve as our compute engine. Using Ubuntu ensures a modern, developer-friendly Linux environment.
  • Networking Stability: By attaching devops-eip, we ensure that the public-facing URL or IP address stays the same forever.
  • Why it Matters: This is critical for pointing DNS records (like api.nautilus.com) to your server. Without an EIP, your website would "go missing" every time the server restarted!

2. Step-by-Step Guide: Provisioning the Infrastructure

We will perform this in two major phases: Launching the server and then Allocating/Associating the IP.

Phase A: Launch the EC2 Instance

  • Navigate to EC2: Log in to the AWS Console and open the EC2 Dashboard.

  • Initiate Launch: Click the orange "Launch instances" button.

  • Configure Details:

    • Name: devops-ec2
    • AMI: Select Ubuntu (Latest LTS).
    • Instance type: Select t2.micro.
    • Key pair: Select your preferred key pair.

  • Finalize: Click "Launch instance" and wait for the status to turn green (Running).


Phase B: Allocate and Associate the Elastic IP

  • Open EIP Dashboard: In the left sidebar, under "Network & Security", click "Elastic IPs".

  • Allocate New IP: Click "Allocate Elastic IP address".

  • Tag and Create: Add a tag (Key: Name, Value: devops-eip) and click "Allocate".


  • Associate with EC2: Select the IP, click "Actions", and select "Associate Elastic IP address".

  • Link Resources: Select your devops-ec2 instance and click "Associate".



Step 2.1: Verify the Setup

  • Check the Public IP: Go back to your Instances list and select devops-ec2.
  • Confirm: Look at the "Public IPv4 address" field. It should now match your Elastic IP exactly!

Success! Your developers now have a stable, high-performance Ubuntu hub. πŸŽ‰


3. Key Takeaways πŸ“

  • Static Identity: The Elastic IP ensures the server is always reachable at the same address.
  • Ubuntu AMI: One of the most popular choices for development due to its extensive library.
  • Cleanup Rule: AWS charges for EIPs that are not attached to a running instance. Release them if you delete the server!

4. Common Mistakes to Avoid 🚫

  • Forgetting Association: Allocation is just "buying" the IP; Association is "using" it.
  • Security Groups: A static IP won't help if Port 22 (SSH) is blocked in your Security Group!
  • Region Mismatch: The EIP must be in the same region as your instance.

5. Conclusion + Call to Action! 🌟

You've just built a production-ready entry point for your dev team! This combination of compute and static networking is a fundamental pattern in AWS architecture.

Top comments (0)