A subnet is a section of a VPC (Amazon Virtual Private Cloud (Amazon VPC)) that can contain resources such as Amazon Elastic Compute Cloud (EC2) instances. You can group resources in a VPC based on security or operational needs.

Public vs Private Subnet

A public subnet contain resources that need to be accessible by the public, such as an online store’s website.

A private subnet contains resources that should be accessible only through your private network, such as a database that contains customers’ personal information and order histories.

In a VPC, subnets can communicate with each other. For example, you might have an application that involves Amazon EC2 instances in a public subnet communicating with databases that are located in a private subnet.