Sub topic 1
What a VPC Is and How It Is Isolated
Prerequisites
Assume you know basic CIDR notation, TCP ports, firewalls, AWS Regions, and Availability Zones (AZs). An AZ is an isolated location within an AWS Region.
VPC isolation
An Amazon Virtual Private Cloud (VPC) is a logically isolated network in AWS. You choose its private IP address range, called a CIDR block. Resources in the VPC communicate through routes that you control.
Isolation does not automatically mean that every resource is private. A subnet can have a path to the internet, and security rules can allow traffic. Treat the VPC as the network boundary, then control access inside it.
Choosing CIDR blocks and planning address space
A VPC CIDR block limits the private addresses available to all its subnets. For example, 10.0.0.0/16 provides a large range. You could reserve 10.0.1.0/24 for public resources and 10.0.2.0/24 for private resources.
Choose ranges that do not overlap with networks you may connect later, such as another VPC or an office network. Leave unused space for new tiers and AZs. Overlapping ranges make routing and VPC connections difficult or impossible.
Carving subnets across Availability Zones
A subnet is a smaller IP range inside a VPC. Each subnet belongs to one AZ. For resilience, create equivalent public and private subnets in at least two AZs.
VPC_ID=$(aws ec2 create-vpc \
--cidr-block 10.0.0.0/16 \
--query 'Vpc.VpcId' --output text)
aws ec2 create-subnet --vpc-id "$VPC_ID" \
--cidr-block 10.0.1.0/24 --availability-zone us-east-1a
aws ec2 create-subnet --vpc-id "$VPC_ID" \
--cidr-block 10.0.11.0/24 --availability-zone us-east-1bControlling traffic paths with route tables
A route table contains destination ranges and next hops. Each subnet uses one route table, either explicitly or through the VPC's main table. A route such as 0.0.0.0/0 matches destinations outside the VPC.
Public subnets and the internet gateway
An internet gateway (IGW) connects a VPC to the internet. A subnet is public when its associated route table sends internet-bound traffic to an IGW. Instances also need a public IPv4 address and security rules that permit the required traffic.
> callout note > A public subnet describes a route. It does not mean every resource in that subnet is automatically exposed.
Exercise
What two conditions make an instance reachable from the internet?
Show answer
Its subnet needs a route to an internet gateway, and the instance needs a public address plus permitting security rules.