NAT gateways are too expensive (2022)

I was looking at my AWS bill and saw a line item called EC2-other which was about half of my bill. It was strange because I only have 1 free tier EC2 instance, and mainly use ECS spot instances for dev. I went through all the regions couldn’t find any other instances, luckily for me the culprit appeared after I grouped by usage. I setup a Nat-gateway, so I could utilize private subnets for development. This matters because I use CDK and Terraform, so having this stuff down during dev makes it easy to transition to prod. I didn’t have any real traffic so why does it cost so much.

The line item suggests to me that a Nat gateway is just a managed nat instance, so I guess I learnt something.

Sorry if I’m incoherent, really spent some time figuring this out and I’m just in rant mode.

this is my guess too. those are dedicated hardware, not shared service. makes sense, as they can deliver quite hefty traffic. same goes for privatelink.

Yes, go with a NAT instance. You can stop it when not needed to save even more.

NAT Gateways are one of the classic AWS gotchas. They can really run up a bill quickly without you realizing it. What’s “funny” is that you can set up your own NAT Gateway on AWS for way cheaper, but I suppose that’s a burden many would rather just pay away.

If you haven’t figured it out yet, a potential way to avoid NAT Gateways (or at least reduce their costs) is to utilize VPC endpoints. Some AWS services support VPC endpoints, and using them would be cheaper than using a NAT gateway.

Lol, I remember using NAT Instance on ec2 micro instead of NAT Gateway for this reason. Spin it up and down as needed as well.

NAT gateway pricing is pretty explicit. Its expensive but can do a ton of bandwidth and its HA.

I use this one for personal accounts - https://github.com/int128/terraform-aws-nat-instance

This advice is shoveling dirt. VPC-endpoints are $0.015 x 720 hr/mo x AZ count

Correct answer is associate an elastic ip (EIP) in public subnet (with internet gateway). Then you only pay for egress

I mean, I suppose it matters what the requirements are. If you can just use a public subnet, then obviously you can avoid VPC endpoints or a NAT Gateway. Why even bother with NAT Gateways or private subnets at all at that point, though?

When you can’t have public subnets (e.g., for security reasons), then you’ll have to figure out another solution. I’m not sure what the situation is with the OP, but presumably they’re avoiding doing exactly what you’re suggesting. I mean, that is the default configuration for the default VPC, after all, so presumably the OP consciously decided to not do it that way. I know that I work on projects that can’t be connected to the internet at all (i.e., I’m forbidden to even use NAT Gateways), so the VPC endpoints are a necessity if I want AWS services to be able to interact with each other.

Yup. You’re not the first to notice this: https://www.lastweekinaws.com/blog/the-aws-managed-nat-gateway-is-unpleasant-and-not-recommended/

use internet gateway not nat gateway. zero trust. cheap too.

I maintain an AL2 based NAT instance AMI that supports ARM if you want to check that out: https://github.com/AndrewGuenther/fck-nat

The NAT gateway is cheaper if you don’t have much traffic (less than maybe 100 GB / mo I think I estimated before) and it takes too much effort to patch your own equivalent NAT instances regularly and rotate them out. Obviously if your team’s time is worth nearer to $0 / patch or the cost of auditing a NAT instance is into the hundreds then the NAT instance is cheaper.

https://github.com/AndrewGuenther/fck-nat

Like a bastion host?

Hey guys unrelated but you guys have any recommendations connecting a local network to aws Windows server at the cheapest rate or VPN is the best way to go about this?

If we’re talking about NAT gateways, it’s safe to assume basic security measures are a requirement.

Huh? Do you understand the purpose(s)/benefits of network address translation? There are three.

Yes, it can even do double duty as a bastion host if you desire.

Just get all the networks speaking the same language and you won’t need any translation.

If you’ve configured a VPC to utilize private subnets you’re doing it properly. You do need a NAT device to talk egress; however, it can rack up costs fast if you don’t harness VPC endpoint gateways and interfaces. I’d recommend turning on flow logs and determining where your traffic is heading when it traverses the nat . If majority is s3 a free gw endpoint will save you tons.