You can use AWS Elastic IPs to enable hybrid architectures by allowing you to connect your on-premises network to your AWS cloud infrastructure. This can be done by creating a Virtual Private Network (VPN) connection between your on-premises network and an Amazon Virtual Private Cloud (VPC) using an Elastic IP as the endpoint. There are several other scenarios where you might use them.
In this article, we’ll cover everything you need to know about AWS Elastic IP addresses. Let’s get started.
Table of Contents
What is AWS Elastic IP?
Amazon Web Services (AWS) Elastic IP (EIP) is an EC2 service feature that allows you to allocate a static, public IPv4 address that can be associated with and disassociated from your AWS instances or AWS NAT Gateway. Once an Elastic IP is associated with an instance, it remains associated with it until it is either explicitly disassociated or the instance is terminated. If an instance fails or is terminated and a new one is launched, the Elastic IP address can be transferred to the new instance. This allows you to maintain the same stable static IP address for your application, even if the underlying instances change.
You can allocate and associate Elastic IP Address using the following technologies:
- AWS Management Console
- AWS CLI
- Infrastructure as Code (IaC) management tools and services:
- AWS SDK
Please note that EPI is a public IP address, and you can only associate an AWS Elastic IP address to one EC2 instance at a time.
When should I use AWS Elastic IP?
You may need to use an AWS Elastic IP when you require static IP addresses for your Amazon EC2 instances. For example, if you need to connect to your instance from outside the Amazon network (bastion host or VPN Gateway) or if you want to run certain applications that require a static IP address.
Another common use case for the AWS Elastic IP addresses is AWS NAT Gateway. AWS NAT Gateway requires AWS Elastic IP to launch.
Some additional reasons might include the following:
- A low-budget, high-availability solution: by assigning an Elastic IP to an EC2 instance, you can ensure that your application is always reachable, even if the underlying instance is replaced.
- Ingress/Egress VPC solution: large enterprise companies implement a central VPC environment for traffic filtering and inspection; solutions deployed in such a VPC might require Elastic IPs to satisfy corporate business and security requirements.
- Security: Elastic IPs can help secure your resources by allowing you to control inbound and outbound traffic to your instances.
- Internet-facing service: Elastic IPs are useful when you have an internet-facing service like a website or application that needs a static IP address.
It’s worth noting that if you don’t need a static IP address or you don’t need to maintain a stable IP address for your application, you may not need to use Elastic IPs. Instead, we recommend launching the instance behind the AWS Elastic Load Balancer (ALB or NLB) in the Auto Scaling Group configuration. You can set the size of Auto Scaling Group to one and rely on Route53 alias records for the application (load balancer) FQDN.
AWS Elastic IP vs. Public IP
AWS Elastic IPs and Public IPs are both types of IP addresses that can be used to access your instances, but they have some key differences:
|AWS Elastic IP||AWS Public IP|
|Use case||Provide a stable, static IP address for your instances/applications||Provide the temporary IP address and access to instances|
|Behavior||Associated with and disassociated from instances as needed||It can change if an instance is terminated or stopped|
|Scope||Allocated to your AWS account||Assigned to instances at launch time|
|Price||Free, but additional charges are applied by hourly rate when they are not associated with a running instance (see below)||Free of charge|
In summary, Elastic IPs are best used when you need a static, publicly-accessible IP address that can be associated with and disassociated from your AWS instances and when you need to maintain a stable IP address for your application, even if the underlying instances change. Public IPs, on the other hand, are best used when you need temporary access to instances and when you don’t need a static IP address.
AWS Elastic IP Pricing
You can have one Elastic IP (EIP) address associated with a running instance at no charge. If you associate additional EIPs with that instance, you will be charged for each additional EIP associated with that instance per hour. You’ll also be charged if you remap (associate and dissociate) EIP more than 100 times a month.
Here are the current EIP charges for N. Virginia region:
- $0.00 per Elastic IP address remap for the first 100 remaps per month
- $0.10 per Elastic IP address remap for additional remaps over 100 per month
- $0.005 per additional IP address associated with a running instance per hour
- $0.005 per Elastic IP address not associated with a running instance per hour
Finally, IPv4 EC2 Elastic IP cost is free if you bring your own IPv4 CIDRs and consume them from your IP address pool.
AWS Elastic IP Limit
Any AWS account is default limited to five (5) Elastic IP addresses per AWS Region. This is a soft limit and may be extended by AWS Support.
AWS Elastic IP and IPv6
You don’t need Elastic IPs when using the IPv6 protocol by the protocol design.