Skip to content

Cloud (AWS) Level 1, Task 5: Allocating an Elastic IP

Today's task was about provisioning a simple but essential piece of cloud networking infrastructure: an AWS Elastic IP (EIP). My objective was to allocate a static public IP address to my account, which is a critical first step for any high-availability application.

This was a great exercise because it demonstrated a core concept of cloud networking: managing static IPs. I've documented both the fast, scriptable AWS CLI method and the visual AWS Console (UI) method, along with a detailed explanation of why EIPs are so important. This is my first-person guide to that process.

Table of Contents


The Task

My objective was to allocate a new AWS Elastic IP address. The requirements were: 1. The EIP's name tag had to be datacenter-eip. 2. The operation had to be performed in the us-east-1 region.


Solution 1: The AWS CLI Method (Automation)

This method is fast, scriptable, and my preferred approach for repeatable tasks. It involves running a single command from the aws-client host.

Phase 1: The Command

  1. I logged into the aws-client host.
  2. I ran the aws ec2 allocate-address command. This single command requests a new EIP from AWS's pool and, with the --tag-specifications flag, applies the required name tag in the same operation.
    aws ec2 allocate-address \
        --domain vpc \
        --tag-specifications 'ResourceType=elastic-ip,Tags=[{Key=Name,Value=datacenter-eip}]' \
        --region us-east-1
    
    (Note: --domain vpc specifies I want an EIP for use in a VPC, which is the modern standard.)

Phase 2: Verification

The command itself outputs a JSON block describing the newly allocated EIP, including its PublicIp and AllocationId. This output is the confirmation of success. I could also have run aws ec2 describe-addresses --filters Name=tag:Name,Values=datacenter-eip to find it.


Solution 2: The AWS Console Method (UI)

This method uses the graphical web interface and is very intuitive.

  1. Login to AWS Console: I used the provided URL, username (kk_labs_user_494893), and password to log in.
  2. Navigate to EC2: In the main console, I ensured my region was set to us-east-1 (North Virginia). I then used the search bar to find and navigate to the EC2 service.
  3. Navigate to Elastic IPs: In the EC2 dashboard's left-hand navigation pane, under "Network & Security," I clicked on Elastic IPs.
  4. Allocate Elastic IP: I clicked the "Allocate Elastic IP address" button in the top right.
  5. Fill in Details:
    • On the allocation page, I scrolled down to the "Tags" section.
    • I clicked "Add tag" and entered Key: Name and Value: datacenter-eip.
  6. Allocate: I clicked the final "Allocate" button. The EIP was created and appeared in my dashboard.

Why Did I Do This? (The "What & Why")

- Dynamic vs. Static IPs (The Problem): By default, when I launch an AWS EC2 instance (a virtual server), it gets a dynamic public IP address. This address is temporary. If I stop and then start the instance, it will get a new, different public IP address. This is a huge problem for a web server, because any DNS records (like www.myapp.com) pointing to the old IP would break, and users would no longer be able to find my site. - Elastic IP (EIP - The Solution): An EIP solves this problem by giving me a static public IP address. It's a permanent address that belongs to my AWS account, not to a specific server. - Why "Elastic"? The "elastic" part comes from its flexibility. I can easily associate it with one of my EC2 instances. If that instance ever fails or needs to be replaced, I can detach the EIP and re-associate the exact same public IP address to a new, healthy instance. My users, who are still pointing their browsers to that same static IP, will experience minimal downtime and won't even know the underlying server has changed. It's a fundamental component for building high-availability and fault-tolerant applications.


Deep Dive: The Anatomy of the allocate-address CLI Command

This task was a perfect demonstration of the power of the AWS CLI.

[Image of an Elastic IP being re-associated from a failed to a healthy server]

aws ec2 allocate-address \
    --domain vpc \
    --tag-specifications 'ResourceType=elastic-ip,Tags=[{Key=Name,Value=datacenter-eip}]' \
    --region us-east-1
- aws ec2 allocate-address: The main command, telling the AWS API that I want to reserve a new public IP from the EC2 service. - --domain vpc: This is a key argument. It specifies that I want an EIP for use in a VPC. The older "EC2-Classic" is deprecated, so this is the modern standard. - --tag-specifications '...': This is the standard, structured way to add tags to a resource at the moment of creation. The ResourceType=elastic-ip specifies I'm tagging the EIP itself, and the Tags list contains my Name tag. - --region us-east-1: Explicitly tells the command to run in the us-east-1 region, as required by the task.


Common Pitfalls

- Cost of Unused EIPs: This is the biggest "gotcha" with Elastic IPs, and a very important one to know. AWS provides an EIP for free as long as it is attached to a running EC2 instance. However, if you allocate an EIP and leave it unattached (or attach it to a stopped instance), AWS will start charging you for it (usually a few dollars a month). This is to encourage people to release the limited supply of IPv4 addresses they aren't actively using. - Regional Scope: Elastic IPs are tied to a specific AWS region. An EIP created in us-east-1 cannot be attached to an instance in us-west-2. - Forgetting to Tag: In a busy account, an untagged EIP is a mystery. It's impossible to know what it's for or if it's safe to delete. Tagging (especially with a Name) is a critical best practice.


Exploring the Commands and UI I Used

AWS CLI Method

  • aws ec2 allocate-address: The primary command for this task. It provisions a new, static public IP from AWS's pool.
  • aws ec2 describe-addresses: A useful verification command to list all EIPs in my account and check their state (associated or unassociated).

AWS Console (UI) Method

  • EC2 Dashboard > Network & Security > Elastic IPs: The main navigation path to the EIP management page.
  • "Allocate Elastic IP address" button: The primary UI element that launches the allocation wizard.