Monday, April 28, 2025

How to Allocate Elastic IP Address from AWS Pool & Associate to an Instance | Overview & Hands-On.

An overview & Hands-On to Allocate Elastic IP Address from AWS Pool & Associate  to an Instance. 

Focus:

  • Tailored for Devops, DevSecops & Cloud Engineers.

Breakdown:

  • Intro,
  • Step 1: Allocate the Elastic IP Address,
  • Step 2: Associate the Elastic IP Address with an Instance,
  • AWS, step-by-step deploy of eip: UI (AWS Console Method),
  • AWS CLI Method,
  • Project: Hands-On,
  • The pricing for elastic ip in aws,
  • Cost Optimization Tips,
  • twtech Final thoughts.

Intro:

  • To allocate an Elastic IP address from an Amazon Web Services (AWS) public IPv4 address pool and associate it with an EC2 instance, twtech must use the Amazon EC2 console or the AWS command line interface (CLI).
  • An Elastic IP address (EIP) in AWS is a static, public IPv4 address that twtech may allocate to its AWS account. 
  • twtech typically uses an Elastic IP to mask the failure of an instance or software by rapidly remapping the address to another instance in twtech account.
  • Unlike regular public IPs that change when twtech stops and start an instance, an Elastic IP stays the same until twtech choose to release it.
Step 1: Allocate the Elastic IP Address.
twtech allocates an EIP using the AWS Management Console:
  1. Open the Amazon EC2 console.
  2. In the navigation pane, under Network & Security, choose Elastic IPs.
  3. Choose Allocate Elastic IP address.
  4. For Public IPv4 address pool, select Amazon's pool of IPv4 addresses.
  5. (Optional) Add a Tag to help identify the EIP, then choose Allocate.
  6. AWS allocates a new EIP from its available pool to twtech account.
Step 2: Associate the Elastic IP Address with an Instance.
Once allocated, you can associate the EIP with your target EC2 instance:
  1. In the Elastic IPs pane of the EC2 console, select the newly allocated EIP .
  2. Choose Actions > Associate Elastic IP address.
  3. For Resource type, ensure Instance is selected.
  4. For Instance, select the ID of the EC2 instance you want to associate the EIP with.
  5. For Private IP address, the primary private IP address of the instance will likely be pre-selected.
  6. Choose Associate.
NB:
  • The EIP is now associated with twtech instance. 
  • If the instance was already running, traffic will immediately begin flowing through this new static IP address.
  • For detailed, official instructions, refer to the Allocate an Elastic IP address and Associate an Elastic IP address documentation within the AWS User Guide.
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/working-with-eips.html

AWS, step-by-step deploy of eip: UI

 AWS Console Method:

  1. Sign in to the AWS Management Console.
  2. Go to the EC2 Dashboard.
  3. In the left menu, scroll down to Network & Security and click Elastic IPs.
  4. Click the Allocate Elastic IP address button.
  5. Choose:
    • Scope (choose "VPC" — default for most cases or twtec-custom-vpc)
    • Public IPv4 Pool (usually "Amazon's pool" unless twtech have its own IPs)
  6. Click Allocate.
  7. After allocation, twtech will see a new Elastic IP address listed.
  8. (Optional) Associate it with an EC2 instance or network interface by selecting it and clicking Associate Elastic IP address.

 AWS CLI Method:

If twtech prefers the command line, it can also do it using AWS CLI:

# bash 
aws ec2 allocate-address --domain vpc

NB:

  • It will return details like the new Elastic IP address and allocation ID.
  • To associate it with an instance:

#  bash
aws ec2 associate-address --instance-id i-xxxxxxxxxxxxx --allocation-id eipalloc-xxxxxxxxxxxxx

The pricing for elastic ip in aws

  • As of April 2025, AWS charges $0.005 per hour for each public IPv4 address, including Elastic IP (EIP) addresses, regardless of whether they are attached to a resource or not. 
    • In-use Elastic IPs: $0.005 per hour when associated with a running EC2 instance or other AWS resources.
    • Idle Elastic IPs: $0.005 per hour when not associated with any resource.
    • Additional Elastic IPs: $0.005 per hour for each additional EIP associated with a running EC2 instance beyond the first one.​
  • These charges apply across all AWS regions, including commercial, AWS China, and GovCloud regions. ​

 AWS Free Tier

  • AWS offers a Free Tier that includes 750 hours of public IPv4 address usage per month for the first 12 months after twtech opens its AWS account.

 Cost Optimization Tips

  • Release Unused EIPs: To avoid unnecessary charges, release Elastic IPs that are no longer in use.
  • Monitor Usage: Utilize AWS tools like Public IP Insights and AWS Cost Explorer to monitor and manage public IP address usage effectively. ​ 

twtech Final thoughts:

Eip are paid, when twtech does not need any , it would disassociate with the instance and release back to aws pool.

  • Static: It doesn’t change over time unless twtech release it.
  • Public: It’s reachable from the internet.
  • Portable: twtech can move it between EC2 instances or network interfaces.
  • Charges: AWS charges twtech if it allocates an Elastic IP but don’t associate it with a running resource (like an EC2 instance). ...Yes, twtech is charged for any eip addresses once created.


Project: Hands-On

  • How twtech allocates an Elastic IP address (eip) and attach it to an instance.
Step-1:
  • Go to ec2 Dashboard.


  • Allocate Elastic IP address from aws pool of eip addresses.

Step-2:

  • Associate or attach eip (twtech-webserver-eip) to instance (twtech-web-server)

  • Choose an instance to associate eip to:


Step-3:

  • twtech Verifies that eip in now attached to instance.


Step-4:

  • How twtech may disassociates eip with instances: if no longer needed ( remember, EIP is paid for)

  • Confirm to disassociate eip:


NB

  • Always release eip back to aws pool, else hourly charge will still be incurred.

  • Confirm to release the eip back to aws pool:


No comments:

Post a Comment

Amazon EventBridge | Overview.

Amazon EventBridge - Overview. Scope: Intro, Core Concepts, Key Benefits, Link to official documentation, Insights. Intro: Amazon EventBridg...