How to assign Elastic IP to Application Load Balancer in AWS?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
When deploying applications on AWS, it's common to use the Application Load Balancer (ALB) to distribute incoming traffic efficiently across multiple targets, such as EC2 instances. However, a typical challenge may arise when you need to assign a static IP address to the ALB. This need can arise for various reasons, such as whitelisting IP addresses in firewall settings or complying with certain network security standards. In AWS, Elastic IP addresses provide a solution by offering a static IP address that can be used in the cloud. However, Elastic IPs cannot be directly associated with an Application Load Balancer. Here's a detailed explanation of how you can work around this limitation.
Understanding the Components
Elastic IP
An Elastic IP (EIP) is a static, public IPv4 address designed for dynamic cloud computing. Elastic IPs are mapped to an AWS account and can be associated with instances or network interfaces.
Application Load Balancer
The Application Load Balancer (ALB) operates at the application layer (OSI layer 7) and is designed for handling HTTP and HTTPS traffic, providing advanced routing and visibility features. Unlike the Network Load Balancer, the ALB does not natively support static IP assignment, which is where the challenge begins.
Elastic Network Interface (ENI)
An Elastic Network Interface (ENI) is a virtual network interface that you can attach to an instance in a VPC, serving as a logical representation of a network card.
Workaround: Using a Network Load Balancer
Since Elastic IPs cannot be directly assigned to an ALB, the solution involves using a Network Load Balancer (NLB) and ALB in tandem:
- Set Up a Network Load Balancer (NLB):
- Create a NLB in the same region as the ALB.
- Assign Elastic IPs to the NLB's subnets. Ensure that these EIPs are allocated in the same Availability Zones as ALB targets.
- Configure the NLB Target Group:
- Create a target group for the NLB, specifying the Application Load Balancer as the target. Use the ALB’s DNS name when specifying the target.
- Integrate ALB with NLB:
- By forwarding the traffic from NLB (using static EIPs) to ALB, you can essentially expose a static IP endpoint for your ALB.
- Update DNS Settings:
- Adjust any necessary DNS settings for your application to reflect the NLB's DNS if your application URL relies on IP addressing.
Example Configuration
Step-by-Step
- Create and Assign Elastic IPs:
- Navigate to the Elastic IPs section in the EC2 Dashboard.
- Allocate a new Elastic IP, ensuring it’s in the desired region.
- Repeat this step for each Availability Zone you wish to use.
- Create a Network Load Balancer:
- Go to the Load Balancers section in the EC2 Management Console.
- Select 'Create Load Balancer'.
- Choose ‘Network Load Balancer’, and assign the Elastic IP addresses to the corresponding Availability Zones and subnets.
- Set Up Target Groups:
- Define a new target group in the console, setting Type to ‘ALB’.
- Enter the ALB DNS as the target, ensuring the traffic from the NLB is routed to the ALB.
- Attach the ALB to the Target Group:
- Ensure the Application Load Balancer has listeners set to forward traffic to the appropriate EC2 targets or ECS services.
- DNS Configuration:
- Update DNS records in Route 53 or your DNS provider to point to the Elastic IP address of the NLB, preserving consistent traffic routing through the new configuration.
Key Considerations
| Feature | Description |
| Elastic IPs | Static, must be allocated per NLB subnet. |
| NLB | Can attach EIPs, operates at OSI Layer 4. |
| ALB Integration | Requires target group configuration. |
| AWS Costs | Additional costs may incur due to using both NLB and ALB. |
| Traffic Routing | NLB forwards traffic to ALB which processes it at Layer 7. |
Additional Details
Cost Implications
Using both an NLB and an ALB might increase operational costs. Evaluate AWS billing and alerts to monitor changes to expenditure.
Security Measures
Ensure that the security groups and network ACLs are configured properly to allow communication between the NLB and ALB, as well as between these and the backend EC2 instances.
Route 53 Configurations
Leverage AWS Route 53 features for health checks and failover scenarios to maintain high availability and resilience.
Through careful planning and execution, you can effectively use Elastic IPs with Application Load Balancers by incorporating an intermediary Network Load Balancer, thus preserving static IP capabilities while enjoying the advanced features of ALB.

