AWS Elastic IP
An Elastic IP address (EIP) is a static public IPv4 address that you allocate to your AWS account. Unlike the public IP that an EC2 instance receives when it starts, which changes when it is stopped and started, an Elastic IP stays yours until you release it.
Key concepts #
- It can be associated with an EC2 instance or a network interface, and moved to another one to fail over quickly.
- A NAT Gateway needs an Elastic IP: it is the public address that the private subnets use to reach the Internet. Allow-lists at third parties can use that fixed address.
- An Elastic IP belongs to a Region and to a VPC (
domain = "vpc"). - For web sites, a load balancer with a DNS name in Route 53 is usually better than an Elastic IP on one instance.
Pricing #
AWS charges for every public IPv4 address, whether it is in use or not, so release the Elastic IPs that you do not need. Check the VPC pricing page.
With Terraform #
The resources are aws_eip and aws_eip_association.
resource "aws_eip" "nat" {
domain = "vpc"
}
See tutorials: