AWS Builder Center
The Hidden Journey of a Request Inside an AWS VPC

The Hidden Journey of a Request Inside an AWS VPC

Ever wondered how a request travels from the internet to an EC2 instance inside AWS? Explore the complete networking journey through Internet Gateways, Route Tables, Load Balancers, Security Groups, and NAT Gateways.

Introduction
We access web applications in seconds, but behind that simple experience is a well-orchestrated network flow.
When an application runs on AWS, a request travels through multiple networking and security components inside a Virtual Private Cloud (VPC).
But have you ever wondered what actually happens between clicking a URL and receiving a response from an EC2 instance?
In this article, we'll follow a real HTTP request from a user on the internet to an application hosted inside a private subnet and understand how AWS networking components work together.
1. Understanding Our AWS Architecture
Before following the request, let's imagine a simple production-style architecture.
Our setup consists of:
- VPC: "10.0.0.0/16" - Public Subnet: "10.0.1.0/24" - Private Subnet: "10.0.2.0/24" - Application Load Balancer (ALB): Deployed in public subnets. - EC2 Instance: Hosting our application inside a private subnet. - Internet Gateway (IGW): Providing internet connectivity to the VPC. - NAT Gateway: Enabling outbound internet access from private resources.
The goal is simple: allow users to access our application without exposing the EC2 instance directly to the public internet.
2. The Journey Begins: A User Sends a Request
Imagine a user opens:
The browser first resolves the domain through DNS.
The DNS record points to our Application Load Balancer.
The user's request travels across the internet towards the ALB.
Key takeaway: The ALB acts as the public entry point to our application, while the application server remains inside a private subnet.
3. Internet Gateway: Connecting the VPC to the Internet
An Internet Gateway (IGW) is attached to our VPC.
It enables communication between resources in the VPC and the public internet when the required routing and security rules are configured.
For our architecture:
- The ALB is deployed in public subnets. - The public subnet route table contains "0.0.0.0/0 → Internet Gateway". - The ALB has internet-facing connectivity.
The Internet Gateway provides the network path, but it does not automatically make every resource in the VPC publicly accessible.
4. Route Tables: Finding the Right Path
Now comes one of the most important networking concepts: Route Tables.
A route table determines where network traffic should be directed.
For example:
Public Subnet Route Table
Destination| Target 10.0.0.0/16| local 0.0.0.0/0| Internet Gateway
Private Subnet Route Table
Destination| Target 10.0.0.0/16| local 0.0.0.0/0| NAT Gateway
The "local" route enables communication within the VPC CIDR.
The public route table sends internet-bound traffic towards the Internet Gateway, whereas the private route table sends internet-bound traffic through the NAT Gateway.
This is how AWS determines the next hop for network traffic.
5. Security Groups: The First Line of Defense
Routing alone doesn't mean traffic is allowed.
Security Groups work like virtual firewalls attached to AWS resources.
In our architecture:
ALB Security Group
- Inbound: Allow HTTPS (443) from the internet. - Outbound: Allow application traffic to the EC2 target.
EC2 Security Group
- Inbound: Allow application traffic only from the ALB Security Group. - Outbound: Allow only the traffic required by the application.
One important feature: Security Groups are stateful.
This means response traffic for an allowed connection is automatically permitted.
This helps us avoid exposing our EC2 instance directly to everyone.
6. Network ACLs: Subnet-Level Protection
Security Groups aren't the only security mechanism.
AWS also provides Network Access Control Lists (NACLs).
NACLs operate at the subnet level.
Here's how they differ:
Security Groups| Network ACLs Resource-level firewall| Subnet-level firewall Stateful| Stateless Allow rules only| Allow and deny rules Return traffic automatically allowed| Return traffic must be explicitly allowed
Think of Security Groups as security guards for individual resources and NACLs as security checkpoints for an entire subnet.
Both work together to control network traffic.
7. The Application Finally Receives the Request
After the routing and security checks, the Application Load Balancer forwards the request to a healthy EC2 target in the private subnet.
The EC2 instance processes the request and generates a response.
The response travels back through the ALB to the user.
An important detail: The ALB establishes a separate connection to the backend target. It isn't simply forwarding the original TCP connection unchanged.
And that's how a user can access an application hosted on an EC2 instance without giving that instance a public IP address.
8. What About the NAT Gateway?
You might be wondering:
If our EC2 instance is inside a private subnet, how can it download software updates, install packages, or communicate with external APIs?
That's where the NAT Gateway becomes useful.
A NAT Gateway allows resources in a private subnet to initiate outbound connections to the internet.
For example:
Private EC2 → NAT Gateway → Internet Gateway → Internet
The NAT Gateway translates the private source address for internet communication.
It does not allow unsolicited internet connections to directly reach the private EC2 instance.
Important: NAT Gateway is not part of the normal inbound user-request path described above. It is primarily used for outbound connectivity initiated by private resources.
9. Why Does This Architecture Matter?
This architecture provides several advantages:
- Better Security: Application servers don't need public IP addresses. - Controlled Access: ALB and EC2 Security Groups restrict traffic. - Scalability: Multiple EC2 instances can be registered behind an ALB. - Network Isolation: Public-facing and application resources are separated. - Controlled Outbound Access: NAT Gateway enables private resources to access external services.
For production environments, we can extend this design using multiple Availability Zones, Auto Scaling Groups, private database subnets, and other AWS services.
Final Thoughts
Understanding AWS VPC isn't just about memorising components or learning their definitions.
It's about understanding how these components communicate and how they work together to build secure and scalable cloud infrastructure.
A single HTTP request involves DNS resolution, routing decisions, network security rules, load balancing, and backend processing.
Once you understand this journey, AWS networking starts becoming much easier to visualise.
Remember: Building cloud infrastructure is easy. Understanding how traffic moves through it is what makes you a cloud engineer.
Let's Discuss!
If you were designing this architecture for a production application, what would you add next?
- Multi-AZ deployment? - Auto Scaling? - AWS WAF? - Private database subnet?
Share your thoughts in the comments. I'd love to hear how others approach AWS networking!
#AWS #AmazonWebServices #AWSVPC #CloudComputing #CloudArchitecture #Networking #EC2 #AWSCommunity
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