Skip to content
shiporbreak

No streak yet

Sign in

November 27, 2026 路 #72

CloudEasyOpen write-up

Private subnet, no internet

An EC2 instance in a private subnet cannot download OS updates. It has no public IP and should stay unreachable from the internet. What do you add?

Next puzzle in UTC

One try. The first answer sticks.

How to fix it

A NAT gateway lets private instances start outbound connections while blocking inbound ones. It sits in a public subnet, and the private route table sends 0.0.0.0/0 to it.

A subnet is "public" in AWS because its route table sends 0.0.0.0/0 to an internet gateway, and its instances have public IPs. A private subnet has no such route, so its instances cannot reach package mirrors, container registries, or external APIs.

A NAT gateway solves this. It lives in a public subnet, has an Elastic IP, and translates outbound traffic from private instances. Return traffic for connections the instance started is allowed back, but nobody on the internet can open a connection in.

Why the other options fail

  • Routing the private subnet straight to the internet gateway only works for instances with a public IP, and it makes the subnet public.
  • Inbound security group rules do not help with outbound connections, and opening them widens exposure.
  • Network ACLs are stateless filters. Allowing 443 does not create a path to the internet.

Fix

resource "aws_nat_gateway" "main" {
  allocation_id = aws_eip.nat.id
  subnet_id     = aws_subnet.public_a.id
}

resource "aws_route" "private_default" {
  route_table_id         = aws_route_table.private.id
  destination_cidr_block = "0.0.0.0/0"
  nat_gateway_id         = aws_nat_gateway.main.id
}

NAT gateways are billed per hour and per GB. For traffic to S3 or DynamoDB, add gateway VPC endpoints so it skips the NAT entirely. For production, use one NAT gateway per availability zone.

Sponsor this spot

Put your tool on the puzzle
One labeled card, in front of engineers who show up every day from YouTube, TikTok, and Instagram.