AWS Builder Center
AWS Networking Fundamentals: Understanding Amazon VPC, Public and Private Subnets

AWS Networking Fundamentals: Understanding Amazon VPC, Public and Private Subnets

Explore the fundamentals of AWS Networking, including Amazon VPC, public and private subnets, Internet Gateways, and route tables. Learn how these components work together through simple explanations and a real-world online shopping application example. This article shares my AWS learning journey and helps beginners understand the basics of cloud networking.

AWS Networking Fundamentals: Understanding Amazon VPC, Public and Private Subnets

Introduction

When we use an online shopping application, we expect it to load quickly, display products, process orders, and store our information securely. But have you ever wondered how all these components communicate with each other?
This is where cloud networking becomes important.
Amazon Web Services (AWS) provides networking services that help applications, servers, databases, and other resources communicate securely and efficiently.
As I continue my learning journey in AWS Cloud Computing, I explored the fundamentals of AWS networking, including Amazon VPC, public and private subnets, Internet Gateways, and route tables.
In this article, let's understand these concepts with simple explanations and a real-world example.

1. What Is AWS Networking?

AWS networking refers to the services and components used to connect AWS resources and control how data travels between them.
For example, imagine an online shopping application. It may have:
  • A website that customers use to browse products.
  • An application server that processes orders.
  • A database that stores customer and order information.
These components need to communicate with one another. At the same time, sensitive information should remain protected from unauthorized access.
AWS networking helps us design and manage these connections.

2. What Is Amazon VPC?

Amazon Virtual Private Cloud (Amazon VPC) allows us to create a logically isolated virtual network within AWS.
Think of a VPC as your own private network in the cloud. You can choose its IP address range, create subnets, configure routing, and control network access.
For example, a company building an online shopping application can create a VPC to host its web servers, application servers, and databases.
This allows the company to organize its resources and control how they communicate.

Why Do We Need a VPC?

A VPC helps us:
  • Organize AWS resources within a virtual network.
  • Divide the network into smaller subnets.
  • Control how traffic moves between different destinations.
  • Connect resources to the internet when required.
  • Separate publicly accessible resources from internal resources.
  • Apply network security controls.
In simple terms, a VPC provides the foundation for designing a network for applications running in AWS.

3. Important Components of Amazon VPC

Let's understand the main components.

A. IP Address Range

When creating a VPC, we define an IP address range using CIDR notation.
For example:
 10.0.0.0/16 
This represents the IPv4 address range assigned to our example VPC.
IP addresses help identify resources and determine where network traffic should go.

B. Subnets

A subnet is a smaller IP address range within a VPC.
We can divide a VPC into multiple subnets to organize resources according to their purpose.
For example:
  • A subnet for web servers.
  • A subnet for application servers.
  • A subnet for databases.
Subnets are associated with specific Availability Zones, which helps us organize resources across different locations within an AWS Region.

C. Internet Gateway

An Internet Gateway connects a VPC to the internet when the appropriate routing and addressing are configured.
For example, if we want customers to access a public website hosted on an EC2 instance, an Internet Gateway can provide the internet connectivity required.
However, attaching an Internet Gateway alone does not automatically make every resource accessible from the internet.
The route table, IP addressing, and security rules must also be configured appropriately.

D. Route Tables

A route table contains rules that determine where network traffic should go.
Think of it as a navigation system for network traffic.
For example, a route table may contain:
Destination
Target
 10.0.0.0/16 
Local
 0.0.0.0/0 
Internet Gateway
The local route allows traffic to be routed within the VPC's address range.
The second route directs other IPv4 traffic toward the Internet Gateway.
Each subnet must be associated with a route table, either explicitly or through the VPC's main route table.

E. Security Groups

Security groups act as virtual firewalls for supported AWS resources.
They control inbound and outbound traffic according to configured rules.
For example, a web server might allow HTTP traffic on port 80 and HTTPS traffic on port 443.
A database server should generally accept connections only from authorized application resources rather than from everyone on the internet.
Security groups are an important part of protecting resources in a VPC.

4. Understanding Public and Private Subnets

One of the most important concepts in AWS networking is the difference between public and private subnets.

What Is a Public Subnet?

A public subnet has a route to an Internet Gateway.
Resources in this subnet can communicate with the internet when they also have the appropriate IP addressing and security configuration.
Example: A public-facing web server that allows customers to access a website.

What Is a Private Subnet?

A private subnet does not have a direct route to an Internet Gateway for ordinary internet access.
It is commonly used for resources that should not be directly accessible from the public internet.
Example: A database server that stores customer information and order details.
A private resource may still need outbound internet access for tasks such as downloading updates. In such cases, a NAT Gateway or another suitable networking solution may be used.

Public vs. Private Subnets

Feature
Public Subnet
Private Subnet
Internet Gateway route
Typically present
No direct Internet Gateway route for ordinary internet access
Common use
Public-facing web servers
Application servers and databases
Direct internet accessibility
Possible with appropriate configuration
Not directly exposed through an Internet Gateway
Security considerations
Restrict inbound and outbound access
Restrict access to required connections
Important: A public subnet does not mean that every resource inside it is automatically accessible to everyone. IP addressing and security rules still matter.
Similarly, a private subnet does not mean that all communication with external networks is impossible.

5. What Is an Internet Gateway?

An Internet Gateway (IGW) is an AWS VPC component that enables communication between a VPC and the internet.
Imagine a building with a controlled entrance. People need an appropriate path to enter or leave the building.
An Internet Gateway provides a network connection between the VPC and the internet, while routing and security configurations determine how that connection can be used.
For a typical IPv4 public web server, the setup requires:
  1. An Internet Gateway attached to the VPC.
  1. A route from the public subnet to the Internet Gateway.
  1. A suitable public IPv4 address for the server.
  1. Appropriate security group rules.
Without the necessary configuration, the server may not be reachable from the internet.

6. How Do Route Tables Work?

A route table tells network traffic where to go based on its destination IP address.
Let's consider a VPC with the address range  10.0.0.0/16 .
Its route table might contain:
Destination
Target
Purpose
 10.0.0.0/16 
Local
Routes traffic within the VPC
 0.0.0.0/0 
Internet Gateway
Routes other IPv4 traffic toward the internet
The local route is created automatically for the VPC's address range.
The default route to the Internet Gateway can be added to the route table associated with a public subnet.
When a customer accesses a website hosted on a properly configured public EC2 instance, network routing helps direct traffic between the customer and the server.
For private subnets, we can configure routing differently to avoid providing a direct internet route.
This separation allows us to design networks according to the needs of our applications.

7. Real-World Example: An Online Shopping Application

Let's imagine a company called ShopEasy that wants to build an online shopping application using AWS.
The application needs to display products, process orders, and store customer information.
We can organize its resources using a VPC with public and private subnets.

Example Architecture

Internet ↓ Internet Gateway ↓ Public Subnet ↓ Web Server ↓ Private Subnet ↓ Application Server ↓ Private Database Subnet ↓ Database
This is a simplified conceptual architecture. In a production environment, the design may include load balancers, multiple Availability Zones, additional security controls, and other services.

How Does It Work?

Step 1: A customer opens the website.
The customer enters the ShopEasy website address in a browser.
Step 2: The request reaches the web server.
The web server is hosted on an appropriately configured resource in the public subnet.
Step 3: The application processes the request.
The web server communicates with the application layer through the permitted network connections.
Step 4: The application accesses the database.
The application server sends a request to the database using the configured database connection and security rules.
Step 5: The response returns to the customer.
The application processes the result and returns the requested information through the web layer.
In this design, the database does not need to be directly accessible from the public internet.
This is one example of how AWS networking can help organize application components and limit unnecessary exposure.

8. How Do Resources Communicate Within a VPC?

Resources within the same VPC can communicate using private IP addresses when the required routing and security rules permit it.
For example, an application server might communicate with a database server using its private IP address.
The VPC's local route supports routing within the VPC's address range. Security groups and other network controls determine whether the required connections are permitted.
Communication between resources in different VPCs requires additional connectivity, such as VPC peering or AWS Transit Gateway, together with appropriate routing and security configuration.
Understanding these connections helps us troubleshoot network issues and design cloud applications more effectively.

9. Key Takeaways

Here are the important points to remember:
  • AWS Networking: Connects AWS resources and controls network traffic.
  • Amazon VPC: Provides a logically isolated virtual network.
  • Subnet: Divides a VPC's IP address range into smaller networks.
  • Public Subnet: Has a route to an Internet Gateway.
  • Private Subnet: Is designed without a direct Internet Gateway route for ordinary internet access.
  • Internet Gateway: Enables communication between a VPC and the internet when properly configured.
  • Route Table: Determines where network traffic should go.
  • Security Group: Controls permitted inbound and outbound traffic for supported resources.
These concepts form the foundation for understanding more advanced AWS networking services.

Conclusion

Learning AWS networking has helped me understand that running an application in the cloud involves more than launching servers. We also need to understand how resources communicate, how traffic is routed, and how access is controlled.
Amazon VPC, subnets, Internet Gateways, and route tables are essential building blocks for designing cloud networks.
As I continue exploring AWS, I look forward to learning more about networking architectures, security, and practical cloud implementations.
If you're also beginning your AWS journey, I hope this article helps you understand the basics of AWS networking.
Keep learning, keep exploring, and keep building!
#AWS #AmazonVPC #AWSNetworking #CloudComputing #AWSCloud #LearningInPublic
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