Skip to main content

Day 4: Create subnets (front yards vs back yards)

ยท 16 min read
Norah Sakal
AI Consultant & Developer

Create subnets (front yards vs back yards)

What you'll learn

How to create 4 subnets (2 public, 2 private) in different availability zones for high availability

Your neighborhood needs housesโ€‹

Day 1: Your AI agent's first phone call Day 1 โ†—
Day 2: Give your AI agent a real-world mission Day 2 โ†—
Day 3: You claimed your territory (VPC) Day 3 โ†—

Today: We'll build our neighborhood with subnets

Think of it like this:

You own a plot of land (VPC)

Now you need to build houses and divide the plots into:

  • Front yard (public subnet) - visitors can visit
  • Back yard (private subnet) - only you can access

We'll build our neighborhood with subnets

We'll build our neighborhood with public subnets (front yards) and private subnets (back yards)

By the end of today, you'll have:

โœ… 4 subnets (2 public front yards, 2 private back yards)
โœ… Resources split across 2 availability zones
โœ… Foundation for security and high availability

Let's build your neighborhood.

What you'll build todayโ€‹

4 subnets in your VPC:

SubnetTypeCIDR BlockZonePurpose
PublicSubnet-1Public172.31.96.0/20us-east-1aLoad balancer
PublicSubnet-2Public172.31.112.0/20us-east-1bLoad balancer
PrivateSubnet-1Private172.31.128.0/20us-east-1aAI containers
PrivateSubnet-2Private172.31.144.0/20us-east-1bAI containers

Why 4 subnets?

  • 2 public = Load balancer (needs internet access)
  • 2 private = AI agent containers (hidden from internet)
  • 2 zones = High availability (if one fails, other works)

What you'll learnโ€‹

  • What subnets are (and why you need them)
  • Public vs private subnets
  • What availability zones are
  • How CIDR blocks divide your VPC
  • How to calculate IP ranges
This advent calendar is completely free.

But if you want:

โœ… Complete codebase (one clean repo)
โœ… Complete walkthroughs
โœ… Support when stuck
โœ… Production templates
โœ… Advanced features

Join the waitlist for the full course (launching February 2026):

Building something with AI calling? Let's chat about your use case!
Schedule a free call โ†— - no pitch, just two builders talking.

Time requiredโ€‹

15 minutes (4 subnets x ~3 minutes each)

Prerequisitesโ€‹

โœ… Completed Day 3 (you have a VPC) โ†—
โœ… Access to AWS Console

Understanding subnets (3-minute primer)โ€‹

What is a subnet?โ€‹

Subnet = Sub-network

It's a logical subdivision of your VPC.

Think of it like:

Your VPC is a city block

Subnets are the individual plots:

  • Some face the street (public)
  • Some are in the back (private)

Every resource in AWS lived in a subnet:

  • Your load balancer โ†’ public subnet
  • Your AI agent containers โ†’ private subnet
  • Databases โ†’ private subnet

Public vs private subnetsโ€‹

What's the difference?

TypeInternet AccessUse CaseExample
Publicโœ… Direct accessWeb servers, load balancersALB
PrivateโŒ No direct accessApp servers, databasesFargate

Key point:

Public subnets have a route to the Internet Gateway

Private subnets don't

We'll set up those routes on Day 6.

Why you need bothโ€‹

Public subnets:

  • Your load balancer lives here
  • Accepts connections from the internet
  • Routes traffic to private subnets

Private subnets:

  • Your AI agent containers love here
  • Can't be accessed directly from the internet
  • More secure

It's like a restaurant:

  • Public subnet = dining room (customers enter here)
  • Private subnet = kitchen (customers can't enter)

Availability zonesโ€‹

What are availability zones?

AWS regions (like us-east-1) have multiple physically separate data centers called availability zones.

Example in us-east-1:

  • us-east-1a = Data center A
  • us-east-1b = Data center B
  • us-east-1c = Data center C

Why this matters:

If one data center has a power outage, the others keep running.

That's why we create 2 subnets of each type:

  • 1 in us-east-1a
  • 1 in us-east-1b

If one availability zone fails, your AI agent keeps working.

Understanding CIDR blocksโ€‹

Remember from Day 3 โ†—: Your VPC uses 172.31.0.0/16
That gives you: 172.31.0.0 โ†’ 172.31.255.255 (65,536 IPs)

Now we need to divide those IPs into subnets.

How CIDR blocks workโ€‹

We'll use /20 blocks: Each gets 4,096 IP addresses

Our plan:

VPC: 172.31.0.0/16 (65,536 IPs)
โ”œโ”€ PublicSubnet-1: 172.31.96.0/20 (172.31.96.0 โ†’ 172.31.111.255)
โ”œโ”€ PublicSubnet-2: 172.31.112.0/20 (172.31.112.0 โ†’ 172.31.127.255)
โ”œโ”€ PrivateSubnet-1: 172.31.128.0/20 (172.31.128.0 โ†’ 172.31.143.255)
โ””โ”€ PrivateSubnet-2: 172.31.144.0/20 (172.31.144.0 โ†’ 172.31.159.255)

Key rules:

  1. Subnets can't overlap
  2. All subnets must be within the VPC range
  3. Use the same /20 size for consistency
Why these specific CIDR blocks?

Deep dive into CIDR blocks.

Understanding the IP ranges

Your VPC might already have subnetsโ€‹

AWS creates default ones.

Check your existing subnets:

  1. Go to VPC
  2. Click subnets
  3. Note the CIDR blocks already in use

Common existing ranges:

  • 172.31.0.0/20 โ†’ 172.31.15.255
  • 172.31.16.0/20 โ†’ 172.31.31.255
  • 172.31.32.0/20 โ†’ 172.31.47.255

We're using 172.31.96.0/20 and higher to avoid conflicts.

Rule: Pick ranges that don't overlap with existing subnets.

Calculator: Use CIDR.xyz โ†— to visualize ranges.

Step 1: Check existing subnetsโ€‹

Before creating new subnets, let's see what already exists.

Open the AWS Console โ†—

In the search bar at the top, type VPC and click VPC from the dropdown:

In the search bar at the top, type VPC and click VPC from the dropdown

In the search bar at the top, type VPC and click VPC from the dropdown

Click Subnets in the left menu:

Click Subnets in the left menu

Click Subnets in the left menu

You'll see your existing subnets:

You'll see existing subnets

You'll see your existing subnets

Note the CIDR blocks already used:

Note the CIDR blocks already used

Note the CIDR blocks already used

Common defaults:

Common default CIDR blocks
172.31.0.0/20
172.31.16.0/20
172.31.32.0/20
172.31.48.0/20
172.31.64.0/20

We'll create new subnets starting at 172.31.96.0/20 to avoid conflicts.

Click and select one of the subnets and you'll see if it is a default one:

Click and select one of the subnets and you'll see if it is a default one

Click and select one of the subnets and you'll see if it is a default one

Step 2: Create PublicSubnet-1โ€‹

Click Create subnet:

Click Create subnet

Click Create subnet

Select your VPC from the dropdown:

Select your VPC from the dropdown

Select your VPC from the dropdown

Fill in the details:

tip

Click the icon

and copy each value from the table below โฌ‡

FieldValue
VPC IDSelect your VPC
Subname name
Availability zone
IPv4 VPC CIDR blockKeep pre-selected 173.31.0.0/16
IPv4 CIDR block
tip

You can also copy and paste the availability zone to make sure you get it right: You can also copy and paste the availability zone to make sure you get it right

Copy and paste the availability zone to make sure you get it right

Fill in the details:

Fill in the details

Fill in the details

Click Create subnet:

Fill in the details and click Create subnet

Fill in the details and click Create subnet

You should now see a successfully created subnet:

You should now see a successfully created subnet

You should now see a successfully created subnet

Step 3: Create PublicSubnet-2โ€‹

Repeat for the second public subnet.

Click Create subnet:

Repeat for the second public subnet. Click Create subnet

Repeat for the second public subnet. Click Create subnet

Fill in the details for PublicSubnet-2:

FieldValue
VPC IDSame VPC
Subnet name
Availability Zone โ† Different zone!
IPv4 VPC CIDR blockKeep pre-selected 173.31.0.0/16
IPv4 CIDR block โ† Different block!

Click Create subnet:

Fill in the details for PublicSubnet-2 and click Create subnet

Fill in the details for PublicSubnet-2 and click Create subnet

โœ… You now have 2 public subnets in 2 availability zones

Step 4: Create PrivateSubnet-1 and PrivateSubnet-2โ€‹

Click Create subnet again:

Click Create subnet again

Click Create subnet again

Select your VPC from the dropdown.

Now create the first private subnet with these values:

FieldValue
VPC IDSame VPC
Subnet name
Availability Zone
IPv4 VPC CIDR blockKeep pre-selected 173.31.0.0/16
IPv4 CIDR block โ† Different block!

This time, click on Add new subnet:

This time, click on Add new subnet

This time, click on Add new subnet

Create the second private subnet with these values:

tip

Click and copy each value from the table below.

FieldValue
VPC IDSame VPC
Subnet name
Availability Zone โ† Different zone!
IPv4 VPC CIDR blockKeep pre-selected 173.31.0.0/16
IPv4 CIDR block โ† Different block!

Click Create subnet:

Click Create subnet

Click Create subnet

โœ… Done! you have now 4 new subnets:

Done, you have now 4 new subnets

โœ… Done! you have now 4 new subnets

Step 5: Verify your subnetsโ€‹

Click on either Subnets in the left menu or Clear filters:

Click on either Subnets in the left menu or Clear filters

Click on either Subnets in the left menu or Clear filters

You should see all 4 new subsets in the list:

You should see all 4 new subsets in the list

You should see all 4 new subsets in the list

Verify:

NameCIDRZoneStatus
PublicSubnet-1172.31.96.0/20us-east-1aAvailable
PublicSubnet-2172.31.112.0/20us-east-1bAvailable
PrivateSubnet-1172.31.128.0/20us-east-1aAvailable
PrivateSubnet-2172.31.144.0/20us-east-1bAvailable

If all 4 show "Available" โ†’ you're done! โœ…

โœ… Today's winโ€‹

If you completed all steps:

โœ… 4 new subnets created
โœ… 2 public (for load balancers)
โœ… 2 private (for AI agent containers)
โœ… Split across 2 availability zones
โœ… IP ranges don't overlap

Tomorrow, we'll build the exit (NAT Gateway)

Understanding what we builtโ€‹

Let's visualize your VPC now:

Let's visualize your VPC now

Let's visualize your VPC now

What you have:
โœ… 1 neighborhood (VPC)
โœ… 2 properties (availability zones)
โœ… 2 front yards (public subnets)
โœ… 2 back yards (private subnets)
โœ… Public/private separation

What you don't have yet:
โŒ Routes (Day 6)
โŒ NAT Gateway (Day 5)
โŒ Security rules (Day 7)

We're building the foundation piece by piece.

Troubleshootingโ€‹

CIDR block overlaps with existing subnet

Error: "CIDR block overlaps with existing subnet"

Solution:

  1. Check your existing subnets (VPC โ†’ Subnets)
  2. Note which CIDR blocks are used
  3. Pick different blocks that don't overlap

Example: If 172.31.96.0/20 is taken, use 172.31.160.0/20

Rule: Each subnet needs a unique range.

Can't select availability zone

Problem: Availability zone dropdown is grayed out

Solution:

  1. Make sure you selected the correct VPC
  2. Refresh the page
  3. Try a different browser

If still stuck: Delete the subnet and try again.

What if I pick the wrong CIDR block?

No problem โ†’ just delete and recreate:

  1. Select the subnet
  2. Click Actions โ†’ Delete subnet
  3. Create a new one with the correct CIDR

Click Actions โ†’ Delete subnet

Click Actions โ†’ Delete subnet

Note: You can only delete subnets that have no resources in them.

Tomorrow's previewโ€‹

Today: You divided your VPC into plots with front yards and back yards (subnets)

Tomorrow (Day 5): We build the exit (NAT Gateway)

Why you need it:

Your private subnets (where your AI agent will live) can't access the internet directly.

But your AI agent needs to:

  • Pull Docker images from ECR
  • Call OpenAI API
  • Send audio to Twilio

Solution: NAT Gateway

It's a one-way door:
โœ… Private subnet โ†’ Internet (outbound)
โŒ Internet โ†’ Private subnet (inbound blocked)

This keeps you AI secure while letting it work.

What we learned todayโ€‹

1. What subnets areโ€‹

Logical divisions of your VPC (like neighborhoods in a city)

2. Public vs privateโ€‹

  • Public = accessible from internet
  • Private = hidden

3. Availability zonesโ€‹

Multiple data centers for high availability

4. CIDR mathโ€‹

How to divide IP ranges without overlaps

The foundation is growingโ€‹

Days 1-2: Local development (your laptop) โœ…
Day 3: VPC (your territory) โœ…
Day 4: Subnets (your neighborhood) โ† YOU ARE HERE โœ…
Days 5-8: Networking (NAT, routes, security)
Days 9-12: Gateway (load balancer, DNS, SSL)
Days 13-17: Deployment (Docker, ECS, production!)
Days 18-24: Features (API, frontend, polish)

Share your progressโ€‹

Got all 4 subnets created? Share it!

Twitter/X:

"Day 4: Created 4 subnets (2 public, 2 private) across 2 availability zones. My AI calling agent's neighborhood is taking shape. Following @norahsakal's advent calendar ๐ŸŽ„"

LinkedIn:

"Day 4 of building AI calling agents: Created subnets for high availability. 2 public for the load balancer, 2 private for the AI containers. Foundation is solid!"

Tag me! I want to celebrate your progress! ๐ŸŽ‰

Want the full course?โ€‹

This advent calendar is completely free.

But if you want:

โœ… Complete codebase (one clean repo)
โœ… Complete walkthroughs
โœ… Support when stuck
โœ… Production templates
โœ… Advanced features

Join the waitlist for the full course (launching February 2026):

Want me to build this for you?

Need help with deployment? Want to brainstorm your AI calling idea? Grab a free 30-min call โ†— - happy to help.

Tomorrowโ€‹

Tomorrow: Day 5 - NAT Gateway (build your one-way door) ๐Ÿšช

Your AI agent needs to call OpenAI and Twilio, but you can't give it a public IP. Solution: NAT Gateway - a one-way door in your back fence.

See you then!

โ€” Norah