Why do i have to create a NAT Gateway per AZ but only one Internet Gateway?

I’m a bit confused about this whole thing. It seems for every AZ with a public/private subnet setup, i need a NAT gateway so the private instances can talk to the internet. But all the public subnets only need a single internet gateway. Why is this?

The public instances have external IPs. The private ones don’t so they need to access through a gateway. The smart thing is to have a bastion in the public that you can use to connect to the private too.

Internet gateway is VPC component that is horizontally scalable.
NAT gateway is AWS managed instance that runs in a public subnet / AZ. Thus if one AZ fails so the NAT gateway will not be available for that AZ.

The public instances have external IPs.

This is not what the OP said. Not to mention it is a fact that you can have instances without public IPs in a public subnet that have public internet egress.

That, and Internet Gateways are already inherently fault tolerant/HA.

Where did you read that you need a NAT gateway per AZ? I have only one NAT gateway per VPC in a two-VPC multi-AZ environment, and that setup works. More likely is that you are being recommended to create a NAT GW per AZ for redundancy/high availability.

The IGW is your VPC’s gateway to the Internet. It is a low level interface, and only gives you a path to the Internet–a default route in networking terms. You only need one because this is not an interface attached to a subnet or AZ but to your VPC itself. Your NAT GW is what provides your environment with a public IP that can then perform network address translation to the private instances in your private subnets.

Internet gateways are more of a logical concept, the machines are already physically connected to internet. Adding a gateway just changes configuration on their network equipment to allow that connectivity.

NAT boxes on the other hand actually are instances that perform an operation (translating private addresses to pubic and vice versa). If you have an IPv6 network and only are interested in IPv6 connectivity, you won’t need NAT.

This is true. You can turn off public DHCP. But it sounded like he was confused with pub/priv VPC

Plz do not do an EC2 nat. And he didn’t say anything about egress for ipv6. At this point I think we’re all inferring too much.

recommended to create a NAT GW per AZ for redundancy/high availability.

Yup, one NAT GW is all that’s needed for functionality. We recently changed to one-per-AZ for this specific reason. If the AZ with the NAT GW went down, or there were routing problems between the AZs, all AZs would be affected. Having one-per-AZ removes those points of failure and minimizes your blast radius.

As others have mentioned you don’t need to create a NAT gateway per AZ if you don’t care about HA for the NAT. You could even have a single VPC that serves as the NAT for all of your other VPCs if you really wanted…

Because a nat gateway is just a nat instance. The only difference is that aws manages it.

About 57 minutes into this episode we get into this in detail, but the whole series on VPCs could be valuable for anyone that has this question: https://mobycast.fm/episode/93-psst-secrets-handling-for-cloud-native-apps-part-1/

While others have mentioned the availability issue, another thing to keep in mind is cross-AZ costs. I’m currently working on fixing a VPC that was deployed with a single NAT gateway shared by multiple AZs of instances, and the NAT gateway is doing large amounts of traffic. Although not as expensive as the NAT gateway data processing fees, the cross-AZ fees that are happening in this deployment are still significant. By simply spinning up a NAT gateway in the other 2 AZs, I increase NAT gateway per-hour costs by $73/month and decrease inter-AZ traffic costs by thousands of dollars a month.

The AWS NAT Gateway is an EC2 instance under the hood that is managed by AWS. Every EC2 instance must belong to one AZ/subnet.

The Internet GW is a construct of AWS software defined network

That said, the cost of NAT GW is too damn high.

. By simply spinning up a NAT gateway in the other 2 AZs, I increase NAT gateway per-hour costs by $73/month and decrease inter-AZ traffic costs by thousands of dollars a month.

I love when this kind of thing gets fixed and the client is like “Oh dang, that ole Matt Buford!!!”

I didn’t mention anything about running EC2 instances as NAT (although if you know what you are doing and can set it up with HA you might save some money) I just implied that the managed NAT is essentially running under the hood as EC2 (same with RDS or even Lambda). Because of that same rules apply as with regular instances.

All good brother! We’re here to help, learn, educate, and advance. Happy new year buddy!

Yeah, it seems you can use just one NAT gateway but then you loose high availability.

Might be a stupid question, but what is the functional difference between an Internet Gateway and NAT Gateway? I 100% get where you use each of them, but at the end of the way isn’t an EC2 instance which has not been assigned a public IP address using some form of NAT to talk to the internet?