SkillSprout
Chapter 4 · Lesson 3
Beginner
5 min read

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

ComponentPurpose
VPCIsolated virtual network with a CIDR range (for example 10.0.0.0/16)
SubnetA range of IPs within one AZ; public or private
Route tableRules that say where network traffic is directed
Internet GatewayConnects a VPC to the internet (two-way)
NAT GatewayLets private instances reach the internet outbound only
Security groupInstance-level, stateful firewall
Network ACLSubnet-level, stateless firewall
VPC endpointPrivate 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

FeatureSecurity groupNetwork ACL
LevelInstance / network interfaceSubnet
StateStateful (return traffic automatic)Stateless (rules for both directions)
RulesAllow onlyAllow and deny
DefaultDenies all inboundDefault NACL allows all
EvaluationAll rulesIn number order

Connecting on-premises to AWS

OptionPathCharacteristics
Site-to-Site VPNOver the public internet, encryptedQuick to set up, variable performance
Direct ConnectDedicated private fibreConsistent bandwidth and latency, not encrypted by default
Client VPNIndividual users to VPCRemote 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

json
{
  "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

bash
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

ServiceReminder
Route 53DNS with health checks and routing policies
CloudFrontCDN with edge caching
Global AcceleratorStatic anycast IPs over the AWS backbone for TCP/UDP
API GatewayManaged front door for APIs
PrivateLink / VPC endpointsReach 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

Public and private subnets
Architecture
VPC 10.0.0.0/16
Internet
Internet Gateway
Public subnet
Load balancer
NAT Gateway
Private subnet
App serversSecurity group
Database
  1. 1Users reach the internet gateway and the load balancer in a public subnet.
  2. 2The load balancer forwards requests to application servers in private subnets.
  3. 3Application servers query the database in the private subnet.
  4. 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