Lesson 04 β Public & Private Subnets
Learning Path
βοΈ Phase 2 β AWS Cloud Security
π Module 04 β Amazon VPC & Network Security
π― Lesson Objective
Section titled βπ― Lesson ObjectiveβBy the end of this lesson, you will be able to:
- Understand what Subnets are.
- Differentiate between Public and Private Subnets.
- Create Subnets using the AWS Console.
- Create Subnets using AWS CLI.
- Verify Subnet configuration.
- Design enterprise network segmentation.
π Lesson Information
Estimated Time: 90 Minutes
Difficulty: Beginner
Prerequisites: Lesson 03 β Amazon VPC Fundamentals
Hands-on Lab: Yes
πΌ Business Value
Section titled βπΌ Business ValueβA VPC is like an office building.
Subnets are the individual floors.
Not every floor should be accessible to visitors.
Some floors are:
- Reception
- Meeting Rooms
Others contain:
- Finance
- HR
- Databases
The same applies in AWS.
Applications exposed to customers should be separated from databases and internal services.
This is called Network Segmentation.
π’ CloudNova Scenario
Section titled βπ’ CloudNova ScenarioβCloudNova is deploying a new Learning Platform.
The architecture requires:
Internet
β
Load Balancer
β
Application Servers
β
DatabaseThe security team decides:
- Load Balancer β Public
- Application Servers β Private
- Database β Private
π What is a Subnet?
Section titled βπ What is a Subnet?βA subnet is a smaller network created inside a VPC.
Every subnet belongs to exactly one Availability Zone.
Example
VPC
10.10.0.0/16
β
βββ Public Subnet
10.10.1.0/24
β
βββ Private App Subnet
10.10.2.0/24
β
βββ Private DB Subnet
10.10.3.0/24Public vs Private Subnets
Section titled βPublic vs Private Subnetsβ| Public | Private |
|---|---|
| Can reach Internet Gateway | No direct Internet access |
| Hosts Load Balancers | Hosts EC2 Applications |
| Hosts Bastion Hosts | Hosts Databases |
| Public IPs allowed | Private IPs only |
| Customer Traffic | Internal Traffic |
π Enterprise Architecture
Section titled βπ Enterprise ArchitectureβInternet
β
Internet Gateway
β
ββββββββββββββββββββββ
Public Subnet
10.10.1.0/24
β
Application Load Balancer
β
ββββββββββββββββββββββ
Private App Subnet
10.10.2.0/24
β
EC2
β
ββββββββββββββββββββββ
Private DB Subnet
10.10.3.0/24
β
Amazon RDSπ Lab 01 β Create Public & Private Subnets (AWS Console)
Section titled βπ Lab 01 β Create Public & Private Subnets (AWS Console)βOpen
AWS Console
β
VPCSelect
Your VPC
10.10.0.0/16Navigate to
Subnets
β
Create SubnetCreate Public Subnet
Example
| Setting | Value |
|---|---|
| Name | Public-Subnet-A |
| VPC | CloudNova-VPC |
| Availability Zone | ap-south-1a |
| IPv4 CIDR | 10.10.1.0/24 |
Click
Create SubnetCreate Private Application Subnet
| Setting | Value |
|---|---|
| Name | Private-App-A |
| Availability Zone | ap-south-1a |
| CIDR | 10.10.2.0/24 |
Create Private Database Subnet
| Setting | Value |
|---|---|
| Name | Private-DB-A |
| Availability Zone | ap-south-1a |
| CIDR | 10.10.3.0/24 |
β Verify
Section titled ββ VerifyβYou should now have
Public-Subnet-A
Private-App-A
Private-DB-Aπ» AWS CLI Lab
Section titled βπ» AWS CLI LabβList VPCs
Section titled βList VPCsβaws ec2 describe-vpcsCreate Public Subnet
Section titled βCreate Public Subnetβaws ec2 create-subnet \ --vpc-id vpc-xxxxxxxx \ --cidr-block 10.10.1.0/24 \ --availability-zone ap-south-1aCreate Private App Subnet
Section titled βCreate Private App Subnetβaws ec2 create-subnet \ --vpc-id vpc-xxxxxxxx \ --cidr-block 10.10.2.0/24 \ --availability-zone ap-south-1aCreate Private Database Subnet
Section titled βCreate Private Database Subnetβaws ec2 create-subnet \ --vpc-id vpc-xxxxxxxx \ --cidr-block 10.10.3.0/24 \ --availability-zone ap-south-1aList Subnets
Section titled βList Subnetsβaws ec2 describe-subnetsFilter by VPC
Section titled βFilter by VPCβaws ec2 describe-subnets \ --filters Name=vpc-id,Values=vpc-xxxxxxxxView Subnet Details
Section titled βView Subnet Detailsβaws ec2 describe-subnets \ --subnet-ids subnet-xxxxxxxxAdd Name Tags
Section titled βAdd Name TagsβPublic
aws ec2 create-tags \ --resources subnet-xxxxxxxx \ --tags Key=Name,Value=Public-Subnet-APrivate App
aws ec2 create-tags \ --resources subnet-yyyyyyyy \ --tags Key=Name,Value=Private-App-APrivate DB
aws ec2 create-tags \ --resources subnet-zzzzzzzz \ --tags Key=Name,Value=Private-DB-AVerify from AWS Console
Section titled βVerify from AWS ConsoleβNavigate to
VPC
β
SubnetsConfirm:
β Correct CIDR
β Correct AZ
β Correct VPC
β Correct Name Tags
π Troubleshooting
Section titled βπ TroubleshootingβProblem
Subnet CIDR overlaps
Solution
Use a different CIDR block.
Problem
Wrong Availability Zone
Solution
Delete and recreate the subnet in the correct AZ.
Problem
Created in wrong VPC
Solution
Delete the subnet and recreate it in the correct VPC.
π’ Enterprise Notes
Section titled βπ’ Enterprise NotesβCloudNova standards:
- One subnet per Availability Zone.
- Never place databases in Public Subnets.
- Public Subnets host only internet-facing components.
- Production databases remain in Private Database Subnets.
- Use consistent naming conventions.
- Tag every subnet with Owner, Environment and Cost Centre.
π« Common Mistakes
Section titled βπ« Common Mistakesββ Using overlapping CIDR blocks.
β Putting databases in Public Subnets.
β Deploying everything in one subnet.
β Ignoring Availability Zones.
β Forgetting resource tags.
π§ͺ DIY Challenge
Section titled βπ§ͺ DIY ChallengeβUsing your own AWS account:
Create:
CloudNova-VPC
β
Public-Subnet-A
10.10.1.0/24
β
Private-App-A
10.10.2.0/24
β
Private-DB-A
10.10.3.0/24Verify:
- All three subnets exist.
- Each subnet belongs to the same VPC.
- Each subnet has the correct CIDR.
- Each subnet is tagged correctly.
Take screenshots of:
- VPC Dashboard
- Subnets page
- Subnet Details
- AWS CLI output (
describe-subnets)
π Knowledge Check
Section titled βπ Knowledge Checkβ- What is a subnet?
- What is the difference between a Public and Private Subnet?
- Can one subnet span multiple Availability Zones?
- Why should databases be placed in Private Subnets?
- Which AWS CLI command lists all subnets?
- Why is network segmentation important?
- What happens if two subnets have overlapping CIDR blocks?
- Why should resources be tagged?
- Which subnet should host an internet-facing Application Load Balancer?
- How do subnets improve security?
π‘ Key Takeaways
Section titled βπ‘ Key TakeawaysβAfter completing this lesson, you should understand:
- Subnets divide a VPC into smaller, manageable network segments.
- Public Subnets host internet-facing resources, while Private Subnets protect internal workloads.
- Every subnet belongs to a single Availability Zone.
- Proper subnet design improves security, scalability and operational management.
- Cloud Security Engineers use both the AWS Console and AWS CLI to create, manage and verify subnets in enterprise environments.
π Next Lesson
Section titled βπ Next Lessonββ‘οΈ Lesson 05 β Route Tables