AWS Builder Center
"The Difference Between Public Subnets and Private Subnets in AWS"

"The Difference Between Public Subnets and Private Subnets in AWS"

"This site is an English translation of the following Japanese site." https://qiita.com/tkazuaki0820/items/f77c768dadfca31147b3

  • Introduction
In this article, I'll explain the difference between public subnets and private subnets in AWS. Before getting into the main topic, let me first explain what subnets are.

What Is a Subnet?

A subnet in AWS is a resource that carves out a segment from a VPC's CIDR block (e.g., 10.0.0.0/16) for a specific Availability Zone (AZ). One subnet is confined to one AZ — you cannot create a subnet that spans multiple data centers (AZs). For redundant configurations, you create one subnet per AZ.

The Difference Between Public and Private Subnets

The official documentation ( https://docs.aws.amazon.com/vpc/latest/userguide/configure-subnets.html ) describes it as follows. In short, the difference comes down to whether or not there is a route to an internet gateway.
  • Public subnet – The subnet has a direct route to an internet gateway. Resources in a public subnet can access the public internet.
  • Private subnet – The subnet does not have a direct route to an internet gateway. Resources in a private subnet require a NAT device to access the public internet.
From a system perspective, there is no inherent difference between subnets themselves — there is no option to select "public" or "private" on the subnet creation screen. Whether a subnet is public or private is determined solely by whether a route table entry pointing to an internet gateway is configured.

What Are the Benefits of Eliminating Public Subnets?

I'll use the regional mode NAT Gateway, which was introduced around last November, as an example. The scenario involves an EC2 instance inside AWS accessing a site on the internet. (This assumes a system where either Zonal NAT Gateway or Regional NAT Gateway can be adopted.)
What stays the same:
  • Outbound communication from inside AWS to the internet, and the associated outbound security measures
  • AWS usage costs
Benefits of eliminating public subnets:
  • The NAT Gateway subnet is created and managed by AWS itself. Reducing the number of subnets that engineers need to create and manage lowers the risk of security incidents caused by human error, such as deploying AWS resources to the wrong subnet.
  • Auto-scaling support becomes available under certain conditions, with multi-AZ support as well.

Closing

This article provided a brief overview of the difference between public and private subnets in AWS. While this is a fundamental aspect of AWS, it's easy to forget — having a solid grasp of these specifications will be valuable when designing AWS network architectures.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article