Blog ENG - AWS - Post 7
An Elastic IP address is a static, public IPv4 address designed specifically for the dynamic nature of cloud computing. This feature allows you to associate an Elastic IP address with any instance or network interface within any Virtual Private Cloud (VPC) in your AWS account. By leveraging Elastic IP addresses, you can unlock a host of benefits that simplify the management and resilience of your cloud-based infrastructure.
Regional Availability
Elastic IP addresses are regional, meaning they are specific to a particular region within AWS. This regional nature ensures that the IP addresses are optimized for performance and availability within that region.
Benefits of Elastic IP Addresses
One of the primary advantages of Elastic IP addresses is their ability to mask the failure of an instance. Should an instance experience an unexpected outage or need to be replaced, you can remap the associated Elastic IP address to another instance within your VPC. This failover process ensures that your applications and services maintain a consistent and reliable public endpoint, minimizing downtime and providing a superior user experience.
Furthermore, Elastic IP addresses offer flexibility in how you manage your network resources. You can programmatically associate and disassociate these addresses as needed, allowing you to direct traffic to different instances based on your evolving business requirements. This dynamic allocation of public IP addresses empowers you to adapt to changing demand, scale your infrastructure, and implement innovative architectures without the constraints of static IP assignments.
Beyond their use for instance failover, Elastic IP addresses can also serve as stable identifiers for your cloud-based resources. This can be beneficial when configuring external services, such as DNS records or firewall rules, to communicate with your AWS-hosted applications. By associating a persistent public IP address, you can future-proof your networking configurations and avoid the need to update external references when underlying instances are replaced or scaled.
How to Use Elastic IP Addresses
To use an Elastic IP address, you first allocate it for use in your account. Then, you can associate it with an instance or network interface in your VPC. Your Elastic IP address remains allocated to your AWS account until you explicitly release it.
An Elastic IP address is a property of a network interface. You can associate an Elastic IP address with an instance by updating the network interface attached to the instance. The advantage of associating the Elastic IP address with the network interface instead of directly with the instance is that you can move all the attributes of the network interface from one instance to another in a single step.
Rules and Limitations
- An Elastic IP address can be associated with a single instance or network interface at a time.
- You can move an Elastic IP address from one instance or network interface to another.
- If you associate an Elastic IP address with the eth0 network interface of your instance, its current public IPv4 address (if it had one) is released to the EC2-VPC public IP address pool. If you disassociate the Elastic IP address, the eth0 network interface is automatically assigned a new public IPv4 address within a few minutes. This doesn’t apply if you’ve attached a second network interface to your instance.
- You’re limited to five Elastic IP addresses. To help conserve them, you can use a NAT device.
- Elastic IP addresses for IPv6 are not supported.
- You can tag an Elastic IP address that’s allocated for use in a VPC, however, cost allocation tags are not supported. If you recover an Elastic IP address, tags are not recovered.
Access and Security
You can access an Elastic IP address from the internet when the security group and network ACL allow traffic from the source IP address. The reply traffic from within the VPC back to the internet requires an internet gateway.
Options for Elastic IP Addresses
- Amazon-provided Elastic IP addresses: When you select this option, you can associate the Elastic IP addresses with a network border group. This is the location from which AWS advertises the CIDR block. Setting the network border group limits the CIDR block to this group.
- Your own IP addresses: You can bring your own IP addresses to AWS.
Cost Allocation and Tagging
Public IPv4 addresses support cost allocation tags. If you apply tags to Elastic IP addresses, you can use those tags to track public IPv4 address costs in AWS Cost Explorer. Before you can use tags as cost allocation tags, you must activate the tags. Note that after you create and apply user-defined tags to your resources, it can take up to 24 hours for the tag keys to appear on your cost allocation tags page for activation.
For all public IPv4 addresses (including public IPv4 addresses assigned to EC2 instances and Elastic IP addresses) that are associated with an elastic network interface, you can view the costs associated with public IPv4 addresses in Cost Explorer by choosing Usage type > PublicIPv4InUseAddress (Hrs).
If a tagged Elastic IP address is not associated with an ENI or is associated with a stopped resource (like a stopped EC2 instance), it’s considered an idle IPv4 address. You can view the costs associated with idle IPv4 addresses in Cost Explorer by choosing Usage type > PublicIPv4IdleAddress (Hrs).
By understanding and effectively utilizing Elastic IP addresses, you can enhance the resilience, flexibility, and cost-efficiency of your AWS infrastructure.