@clementvial

Developer from Canada 🇨🇦
Product, infrastructure, AI, and web3.
Mostly on AWS and Cloudflare.

All notes

Finding the Public IPv4 Addresses You Forgot About

Since February 1, every public IPv4 address costs $0.005 per hour. Attached or idle, it doesn’t matter. That’s about $3.60 a month per address, which is nothing until you count how many you have.

The charge is easy to underestimate because the addresses aren’t all in EC2. RDS instances with public accessibility, load balancers, NAT Gateways, EKS nodes, Global Accelerator, and Site-to-Site VPN tunnels all carry one.

Count them first

Public IP Insights, part of VPC IPAM, lists every public IPv4 address across your accounts and regions. It’s free, and turning it on only requires creating an IPAM pool.

It’s worth doing before you optimize anything, because the distribution is usually lopsided. Most accounts I’ve looked at have a handful of addresses doing real work and a long tail of forgotten Elastic IPs from experiments.

Fargate is the sneaky one

A task with assignPublicIp: ENABLED gets a public address for its entire lifetime and is billed for it. That’s fine for a service running three tasks. It’s less fine for a scheduled job that runs a thousand short tasks a day, where each one bills a partial hour.

Don’t reach straight for NAT

The obvious fix is to move everything into private subnets behind a NAT Gateway. Check the arithmetic before you do.

A NAT Gateway is roughly $32 a month before a single byte moves through it, and it has a public IPv4 address of its own that you now also pay for. Replacing nine addresses with one gateway is a worse deal than it sounds, unless the traffic justifies it independently.

Cheaper options, in the order I’d try them:

  • Release idle Elastic IPs. This is most of the win, and it costs nothing.
  • Use EC2 Instance Connect Endpoint for SSH instead of giving instances a public address purely for access.
  • Add VPC endpoints so private instances reach AWS services without any egress path at all.
  • Bring your own IP range if you have one. BYOIP addresses aren’t charged.

The pricing change is small per unit and entirely proportional to sprawl. Which is presumably the point.