Networking: VPC and Connectivity
Overview
A Virtual Private Cloud (VPC) is your own logically isolated section of the AWS cloud where you launch resources. You decide the IP address range, create subnets, control routing and set firewall rules - much like designing the network of your own data center, without cables.
Picture a gated estate. The estate (VPC) is divided into streets (subnets). The main gate (internet gateway) links it to the outside world. Some streets are public and face visitors, others are private and only reachable from inside. Guards at each house (security groups) and at each street entrance (network ACLs) check who may pass.
You do not need to calculate subnets for the Cloud Practitioner exam, but you must know the purpose of each component and the options for connecting to AWS from outside.
Key Concepts
- A VPC is a private network in a Region, spanning multiple AZs; a subnet lives in one AZ.
- Public subnets have a route to an Internet Gateway (IGW); private subnets do not, and use a NAT Gateway for outbound-only internet access.
- Security groups are stateful virtual firewalls at the instance level (allow rules only).
- Network ACLs (NACLs) are stateless firewalls at the subnet level with allow and deny rules.
- Site-to-Site VPN creates an encrypted tunnel over the internet; AWS Direct Connect is a dedicated private network connection.
- VPC peering privately connects two VPCs; Transit Gateway hubs many VPCs and on-premises networks.
- VPC endpoints / AWS PrivateLink let you reach AWS services privately without traversing the internet.
- Route 53 provides DNS and Elastic Load Balancing distributes traffic into the VPC.
Detailed Notes
VPC building blocks
| Component | Purpose |
|---|---|
| VPC | Isolated virtual network with a CIDR range (for example 10.0.0.0/16) |
| Subnet | A range of IPs within one AZ; public or private |
| Route table | Rules that say where network traffic is directed |
| Internet Gateway | Connects a VPC to the internet (two-way) |
| NAT Gateway | Lets private instances reach the internet outbound only |
| Security group | Instance-level, stateful firewall |
| Network ACL | Subnet-level, stateless firewall |
| VPC endpoint | Private connection to AWS services |
A subnet is public only because its route table sends 0.0.0.0/0 to an Internet Gateway. Typical design: web servers in public (or behind a load balancer), application and database tiers in private subnets.
Security groups versus NACLs
| Feature | Security group | Network ACL |
|---|---|---|
| Level | Instance / network interface | Subnet |
| State | Stateful (return traffic automatic) | Stateless (rules for both directions) |
| Rules | Allow only | Allow and deny |
| Default | Denies all inbound | Default NACL allows all |
| Evaluation | All rules | In number order |
Connecting on-premises to AWS
| Option | Path | Characteristics |
|---|---|---|
| Site-to-Site VPN | Over the public internet, encrypted | Quick to set up, variable performance |
| Direct Connect | Dedicated private fibre | Consistent bandwidth and latency, not encrypted by default |
| Client VPN | Individual users to VPC | Remote workforce access |
Connecting VPCs and services
- VPC peering: one-to-one, non-transitive.
- Transit Gateway: central hub for many VPCs and VPNs.
- Gateway endpoints (S3, DynamoDB) and interface endpoints (PrivateLink): keep traffic on the AWS network.
Example: public web server rules
{
"GroupName": "web-sg",
"IpPermissions": [
{ "IpProtocol": "tcp", "FromPort": 443, "ToPort": 443, "IpRanges": [{ "CidrIp": "0.0.0.0/0" }] },
{ "IpProtocol": "tcp", "FromPort": 22, "ToPort": 22, "IpRanges": [{ "CidrIp": "203.0.113.0/24" }] }
]
}
HTTPS is open to the world while SSH is limited to the corporate IP range - never leave management ports open to everyone.
Creating a VPC
aws ec2 create-vpc --cidr-block 10.0.0.0/16
aws ec2 create-subnet --vpc-id vpc-0abc123 --cidr-block 10.0.1.0/24 --availability-zone ap-south-1a
aws ec2 create-internet-gateway
Edge, caching and DNS helpers
| Service | Reminder |
|---|---|
| Route 53 | DNS with health checks and routing policies |
| CloudFront | CDN with edge caching |
| Global Accelerator | Static anycast IPs over the AWS backbone for TCP/UDP |
| API Gateway | Managed front door for APIs |
| PrivateLink / VPC endpoints | Reach AWS services privately without the internet |
Default VPC
Every Region of a new account has a default VPC with public subnets so you can launch instances immediately. For production, create your own VPC with a deliberate design.
Real World Example
A booking company builds a VPC with public subnets holding a load balancer and private subnets holding application servers and a database, across two AZs. App servers reach the internet for software updates only through a NAT Gateway, and reach S3 through a gateway endpoint to avoid NAT data charges.
Its on-premises payroll system is linked by Site-to-Site VPN now, with plans to upgrade to Direct Connect as volumes grow.
Architecture Diagram
- 1Users reach the internet gateway and the load balancer in a public subnet.
- 2The load balancer forwards requests to application servers in private subnets.
- 3Application servers query the database in the private subnet.
- 4Outbound updates leave through the NAT Gateway; inbound access is blocked.
Best Practices
- ✓Place only load balancers and bastions in public subnets; keep app and data tiers private.
- ✓Use security groups as the primary firewall with least-privilege rules.
- ✓Spread subnets over multiple AZs for availability.
- ✓Use VPC endpoints to reach S3 and DynamoDB privately and reduce NAT costs.
- ✓Use Direct Connect for steady, high-volume hybrid traffic and VPN as backup or quick start.
Common Interview Questions
Exam Tips
CLF-C02 focus
- "Isolated virtual network" = VPC; "subnet-level stateless firewall" = NACL.
- "Dedicated private connection to AWS" = Direct Connect; "encrypted over internet" = Site-to-Site VPN.
- "Private subnet outbound internet" = NAT Gateway.
- "Connect many VPCs and on-premises" = Transit Gateway.
Finished this lesson?
0 of 43 lessons done · 0% of the course

