Module 1

AWS Fundamentals

Build a secure network foundation with VPC, subnets, Internet Gateway, NAT Gateway, and Security Groups.

VPCSubnetsIGWNATSecurity Groups

What You'll Build

Every AWS deployment starts with networking. In this module you'll create a production-grade VPC with public and private subnets, gateways, route tables, and security groups โ€” step by step through the AWS Console.

Module 1 โ€” Resource Checklist

0/12 (0%)
  • โ˜VPC
    sandbox-vpc
  • โ˜Internet Gateway
    sandbox-igw
  • โ˜Public Subnet AZ-a
    sandbox-public-1a
  • โ˜Public Subnet AZ-b
    sandbox-public-1b
  • โ˜Private Subnet AZ-a
    sandbox-private-1a
  • โ˜Private Subnet AZ-b
    sandbox-private-1b
  • โ˜NAT Gateway
    sandbox-nat
  • โ˜Public Route Table
    sandbox-public-rt
  • โ˜Private Route Table
    sandbox-private-rt
  • โ˜ALB Security Group
    sandbox-alb-sg
  • โ˜EC2 Security Group
    sandbox-ec2-sg
  • โ˜RDS Security Group
    sandbox-rds-sg

Azure โ†” AWS Mapping

AzureAWSNotes
VNetVPCAWS requires explicit Internet Gateway
SubnetSubnetSame concept, route tables per subnet
NSGSecurity GroupAWS SGs are allow-only, no deny rules
Route TableRoute TableIdentical concept
(implicit)Internet GatewayAzure VNets auto-get internet; AWS needs IGW
NAT GatewayNAT GatewaySame purpose! ~$32/mo in AWS
โ˜๏ธ Azure Parallel

Biggest difference: In Azure, a VNet automatically has internet access. In AWS, you must create an Internet Gateway, attach it, and configure route tables.


Step 1: Create the VPC

A VPC (Virtual Private Cloud) is your isolated network in AWS. Think of it as your own private data center with a defined IP range.

๐Ÿ“˜ Key Concept

CIDR cheat sheet: 10.0.0.0/16 = 65,536 IPs.10.0.1.0/24 = 256 IPs. Each subnet gets a slice of the VPC's CIDR range.

๐Ÿงช

Console: VPC โ†’ Your VPCs โ†’ Create VPC

SettingValue
Resources to createVPC only
Name tagsandbox-vpc
IPv4 CIDR block10.0.0.0/16
IPv6 CIDR blockNo IPv6
TenancyDefault

Click Create VPC.


Step 2: Create the Internet Gateway

The Internet Gateway (IGW) allows resources in public subnets to access the internet. Azure VNets get this automatically โ€” AWS requires an explicit gateway that you attach to your VPC.

๐Ÿงช

Console: VPC โ†’ Internet gateways โ†’ Create internet gateway

SettingValue
Name tagsandbox-igw

Click Create internet gateway.

Then attach it to your VPC:

  1. Select sandbox-igw
  2. Click Actions โ†’ Attach to VPC
  3. Select sandbox-vpc
  4. Click Attach internet gateway

Step 3: Create Subnets (4 total)

Subnets divide your VPC into segments. You need 2 public and 2 private subnets across 2 Availability Zones for high availability.

  • Public subnets โ€” For the ALB and NAT Gateway (internet-facing)
  • Private subnets โ€” For EC2 instances and RDS (internal only)
๐Ÿงช

Console: VPC โ†’ Subnets โ†’ Create subnet

Select VPC: sandbox-vpc, then add all 4 subnets:

Subnet 1 โ€” Public AZ-a

SettingValue
Subnet namesandbox-public-1a
Availability Zoneus-east-1a
IPv4 CIDR block10.0.1.0/24

Subnet 2 โ€” Public AZ-b

SettingValue
Subnet namesandbox-public-1b
Availability Zoneus-east-1b
IPv4 CIDR block10.0.2.0/24

Subnet 3 โ€” Private AZ-a

SettingValue
Subnet namesandbox-private-1a
Availability Zoneus-east-1a
IPv4 CIDR block10.0.10.0/24

Subnet 4 โ€” Private AZ-b

SettingValue
Subnet namesandbox-private-1b
Availability Zoneus-east-1b
IPv4 CIDR block10.0.11.0/24

Tip: Click "Add new subnet" to create all 4 in one go.

๐Ÿงช

Enable auto-assign public IPs (public subnets only)

  1. Select sandbox-public-1a
  2. Actions โ†’ Edit subnet settings
  3. Check โœ… Enable auto-assign public IPv4 address
  4. Click Save
  5. Repeat for sandbox-public-1b
โ˜๏ธ Azure Parallel

In Azure, subnets in a VNet are "private" by default and you use NSGs to control access. In AWS, the route table determines if a subnet is public โ€” a route to the IGW makes it public.


Step 4: Create Route Tables

Route tables control where network traffic goes. You need a public one (routes to IGW) and a private one (routes to NAT Gateway).

๐Ÿงช

Console: VPC โ†’ Route tables โ†’ Create route table

Public Route Table

SettingValue
Namesandbox-public-rt
VPCsandbox-vpc

Click Create route table.

Add internet route:

  1. Select sandbox-public-rt
  2. Tab: Routes โ†’ Edit routes โ†’ Add route
DestinationTarget
0.0.0.0/0Internet Gateway โ†’ sandbox-igw

Click Save changes.

Associate with public subnets:

  1. Tab: Subnet associations โ†’ Edit subnet associations
  2. Select both: sandbox-public-1a and sandbox-public-1b
  3. Click Save associations
๐Ÿงช

Create Private Route Table

SettingValue
Namesandbox-private-rt
VPCsandbox-vpc

Click Create route table.

Associate with private subnets:

  1. Tab: Subnet associations โ†’ Edit subnet associations
  2. Select: sandbox-private-1a and sandbox-private-1b
  3. Click Save associations

We'll add the NAT Gateway route in the next step.


Step 5: Create a NAT Gateway

The NAT Gateway lets private subnet resources make outbound internet requests (e.g., downloading updates, API calls) without being directly accessible from the internet. It's a one-way door โ€” traffic goes out only.

โš ๏ธ Warning

Cost alert: NAT Gateways cost ~$0.045/hr (~$32/month). Delete when not actively learning!

๐Ÿงช

Console: VPC โ†’ NAT gateways โ†’ Create NAT gateway

SettingValue
Namesandbox-nat
Subnetsandbox-public-1a (must be public!)
Connectivity typePublic
Elastic IPClick Allocate Elastic IP

Click Create NAT gateway. Wait ~2 minutes for status Available.

Now add NAT route to the private route table:

  1. Go to VPC โ†’ Route tables โ†’ select sandbox-private-rt
  2. Tab: Routes โ†’ Edit routes โ†’ Add route
DestinationTarget
0.0.0.0/0NAT Gateway โ†’ sandbox-nat

Click Save changes.


Step 6: Create Security Groups

Security Groups are stateful firewalls attached to resources. They are allow-only (no deny rules) and stateful (return traffic is automatically allowed).

You'll create 3 security groups that form a chain:

text
Internet โ†’ [ALB SG: allow 80/443 from anywhere]
              โ†’ [EC2 SG: allow 3000 from ALB SG only]
                  โ†’ [RDS SG: allow 5432 from EC2 SG only]
๐Ÿงช

Console: VPC โ†’ Security groups โ†’ Create security group

1. ALB Security Group

SettingValue
Namesandbox-alb-sg
DescriptionAllow HTTP/HTTPS from internet to ALB
VPCsandbox-vpc

Inbound rules:

TypePortSource
HTTP800.0.0.0/0
HTTPS4430.0.0.0/0

2. EC2 Security Group

SettingValue
Namesandbox-ec2-sg
DescriptionAllow app traffic from ALB only
VPCsandbox-vpc

Inbound rules:

TypePortSource
Custom TCP3000sandbox-alb-sg (select SG, not IP!)

3. RDS Security Group

SettingValue
Namesandbox-rds-sg
DescriptionAllow PostgreSQL from EC2 only
VPCsandbox-vpc

Inbound rules:

TypePortSource
PostgreSQL5432sandbox-ec2-sg (select SG!)
๐Ÿ’ก Tip

Key insight: Each SG references the previous SG as its source โ€” not IP ranges. This creates a security chain that stays valid even when IPs change.


Key Takeaways

  • VPCs are isolated networks โ€” always start here before deploying anything
  • Use public subnets for ALB and NAT Gateway only
  • Keep EC2 and RDS in private subnets โ€” never expose them directly
  • Security Groups reference each other to create a defense chain
  • Always deploy across at least 2 AZs for high availability
  • Delete the NAT Gateway when not actively testing (~$32/month!)