Epitomsoft Academy · Cloud & DevOps course

Your Private Network in the Cloud (AWS VPC)

Design a secure, highly available network on AWS from scratch: address ranges, public and private subnets, gateways, route tables, firewalls, VPN and private endpoints – with diagrams, real examples and infrastructure-as-code.

What you will learn

Design networks like a cloud architect

Every cloud application lives inside a network. In this course you design the network for the “campus jobs” app: secure by default, resilient across two data centres, connected to the company office – and described entirely as code.

  • Plan IP address ranges (CIDR) for a VPC and its subnets
  • Separate public and private subnets across availability zones
  • Use Internet Gateways, NAT gateways and route tables correctly
  • Apply security groups and network ACLs in layers
  • Connect on-premises networks with VPN or Direct Connect
  • Reach AWS services privately with VPC endpoints, and audit traffic with flow logs

Course at a glance

  • Sessions: 2 animated video lessons + reading + lab
  • Level: Beginner to intermediate
  • Prerequisites: Basic networking (IP addresses, ports) – explained in the course
  • You will build: A two-zone production VPC defined in Terraform/OpenTofu, with layered security

Session 1 of 2

VPC building blocks

Design the campus-jobs network: address range, public and private subnets in two availability zones, Internet Gateway, NAT gateways and route tables.

VPC 10.0.0.0/16 Availability zone A Availability zone B 1 2 3 4 5 6 7 8 Internet Users & updates Internet Gateway VPC ↔ internet Public subnet A 10.0.1.0/24 Public subnet B 10.0.2.0/24 NAT gateway Outbound only Private subnet A 10.0.3.0/24 Private subnet B 10.0.4.0/24 Route tables Where traffic goes
Live example
Read the full transcript
  1. Welcome: Hi, I am Epi! In this course you will build your own private network in the cloud: an Amazon VPC. Our example: designing the network for the campus jobs app, so it is secure, highly available and ready to grow.
  2. Step 1 · VPC & gateway: A VPC is your own isolated network inside AWS, with an address range you choose, such as ten dot zero dot zero dot zero slash sixteen, which gives you about sixty-five thousand addresses. Nothing can reach it from the internet until you attach an Internet Gateway.
  3. Step 2 · Public subnet A: We split the VPC into subnets. Public subnets have a route to the Internet Gateway, and they hold internet-facing resources such as load balancers. Subnet A lives in availability zone A.
  4. Step 3 · Second zone: We add a second public subnet in another availability zone, which is a separate data center. If one zone has a problem, the other keeps the app running. This is called high availability.
  5. Step 4 · Private subnets: Application servers and databases go in private subnets. They have no route from the internet, so attackers cannot reach them directly. Only the load balancer in the public subnet talks to them.
  6. Step 5 · NAT gateway: Private servers still need to download updates. A NAT gateway in a public subnet lets them make outbound connections, while blocking any connection that starts from the internet.
  7. Step 6 · Out to the internet: The NAT gateway sends that outbound traffic through the Internet Gateway, using its own public IP address. For resilience, production designs often run one NAT gateway in each availability zone.
  8. Step 7 · Route tables: Route tables decide where traffic goes. The private route table says: traffic for the VPC stays local, and everything else, zero dot zero dot zero dot zero slash zero, goes to the NAT gateway.
  9. Step 8 · Associations: Every subnet is associated with a route table. The public route table sends internet traffic to the Internet Gateway, and private subnet B gets its own route through the NAT gateway in its zone.
  10. Recap: Your VPC now has an address range, public and private subnets in two availability zones, an Internet Gateway, NAT gateways and route tables. In the next session, we control traffic and security.

Session 2 of 2

Traffic and security

Control exactly who can talk to what: security groups, network ACLs, VPN to the office, safe admin access and private endpoints.

VPC 10.0.0.0/16 · private subnets 1 2 3 4 5 6 7 8 Users HTTPS Load balancer SG: 443 from anywhere Corporate office 192.168.0.0/16 Admin access Session Manager App servers SG: 8080 from ALB Site-to-site VPN Encrypted tunnel Network ACL Subnet firewall Database (RDS) SG: 5432 from app VPC endpoint Private S3 access
Live example
Read the full transcript
  1. Welcome: Welcome to session two! Now we control exactly who can talk to what inside the VPC, and connect it safely to a corporate office. We continue with the campus jobs network.
  2. Step 1 · Load balancer: Users connect over HTTPS to the Application Load Balancer in the public subnets. Its security group allows port four four three from anywhere, and nothing else.
  3. Step 2 · App servers: The load balancer forwards requests to the app servers in private subnets. Their security group only allows traffic coming from the load balancer’s security group, never directly from the internet.
  4. Step 3 · Database: The database security group only allows the database port from the app servers. Security groups are stateful: when a request is allowed in, the response is automatically allowed back out.
  5. Step 4 · Network ACLs: Network ACLs add a second layer at the edge of each subnet. They are stateless, so you must allow both directions, and rules are checked in number order. Use them for broad rules, such as blocking a bad IP range.
  6. Step 5 · VPN: The company office needs access too. A site-to-site VPN creates an encrypted tunnel over the internet. For more bandwidth, AWS Direct Connect provides a private, dedicated line.
  7. Step 6 · Private access: Through the tunnel, office staff reach internal services using private IP addresses, while those services stay invisible to the internet. The office and VPC address ranges must not overlap.
  8. Step 7 · Admin access: Administrators need server access. Instead of opening SSH to the internet, use AWS Systems Manager Session Manager: no inbound ports are opened, and every session is logged. A hardened bastion host is the traditional alternative.
  9. Step 8 · Endpoints & logs: Finally, VPC endpoints let private servers reach AWS services such as S3 without going through the internet or the NAT gateway, which is more secure and cheaper. VPC flow logs record the traffic for auditing.
  10. Recap: Layered security: security groups on every resource, network ACLs on every subnet, private subnets, an encrypted VPN, Session Manager and private endpoints. Congratulations, you have completed the private cloud network course!

Deep dive

Key concepts, explained with examples

VPC and CIDR blocks

A VPC is a logically isolated network in one AWS region. Its size is set by a CIDR block: /16 gives 65,536 addresses, /24 gives 256. Plan ranges that do not overlap with your office or other VPCs.

Example: 10.0.0.0/16 for production, 10.1.0.0/16 for staging, office on 192.168.0.0/16 – no overlaps, so they can be connected later.

Subnets and availability zones

A subnet is a slice of the VPC inside one availability zone (a separate data centre). Spread every tier across at least two zones. AWS reserves 5 addresses in each subnet.

Example: A /24 subnet gives 251 usable addresses; public-a in us-east-1a and public-b in us-east-1b.

Public vs private subnets

A public subnet has a route to an Internet Gateway; a private subnet does not. Put only what must face the internet – load balancers, NAT gateways – in public subnets.

Example: The load balancer is public; app servers and databases are private and unreachable from the internet.

Internet Gateway

A horizontally scaled, highly available gateway that connects the VPC to the internet for resources with public IP addresses. One per VPC.

Example: Without an Internet Gateway, nothing in the VPC can reach the internet – or be reached from it.

NAT gateway

Lets private resources start outbound connections (updates, external APIs) while blocking inbound connections. It is billed per hour and per GB, so use one per zone for resilience and remove unused ones.

Example: An app server downloads security patches through the NAT gateway, but no one on the internet can connect to it.

Route tables

Each subnet uses a route table that decides where traffic goes. The most specific matching route wins; the “local” route keeps VPC traffic inside the VPC.

Example: Private route table: 10.0.0.0/16 → local; 0.0.0.0/0 → NAT gateway; 192.168.0.0/16 → VPN.

Security groups

Stateful virtual firewalls attached to resources. They contain only allow rules, and can reference other security groups instead of IP addresses.

Example: DB security group: allow 5432 only from the app security group – even new app servers are allowed automatically.

Network ACLs

Stateless firewalls at the subnet boundary, with numbered allow and deny rules evaluated in order. Because they are stateless, return traffic (ephemeral ports) must be allowed explicitly.

Example: Rule 90 denies a known malicious range for the whole subnet before any other rule is checked.

VPN and Direct Connect

Site-to-site VPN builds encrypted IPsec tunnels over the internet; AWS Direct Connect is a dedicated private connection with consistent performance. Transit Gateway connects many VPCs and offices in a hub.

Example: The office reaches internal dashboards over VPN today, and moves to Direct Connect when traffic grows.

Endpoints, Session Manager and flow logs

Gateway endpoints (S3, DynamoDB) and interface endpoints (PrivateLink) keep AWS traffic off the internet. Session Manager gives shell access without open ports. Flow logs record accepted and rejected traffic.

Example: Flow logs show repeated REJECTs on port 22 – proof the closed SSH port is blocking scanners.

Security in layers

Security groups vs network ACLs – and other clouds

Use both: security groups for precise per-resource rules, NACLs for broad subnet-wide guard rails.

Security group

Per resource · stateful

Allow rules only · return traffic automatic · can reference other security groups · all rules evaluated together.

Network ACL

Per subnet · stateless

Allow and deny rules · numbered, first match wins · return traffic must be allowed explicitly.

Microsoft Azure

Virtual Network (VNet)

Subnets, Network Security Groups, NAT Gateway, VPN Gateway, ExpressRoute and Private Endpoints.

Google Cloud

VPC network

Global VPC with regional subnets, firewall rules, Cloud NAT, Cloud VPN, Cloud Interconnect and Private Service Connect.

Infrastructure as code

Terraform / OpenTofu

Describe the whole network in code, review it in pull requests and recreate it identically in any account.

Cost tip

Watch the NAT gateway

NAT gateways and data transfer are common surprise costs – use gateway endpoints for S3 and delete lab resources.

Worked examples

Address plan, Terraform and CLI

The campus-jobs network from the animated sessions, as a real design you can deploy.

Example 1 – IP address plan

VPC campus-jobs            10.0.0.0/16    65,536 addresses
├─ public-a   us-east-1a   10.0.1.0/24    load balancer, NAT gateway A
├─ public-b   us-east-1b   10.0.2.0/24    load balancer, NAT gateway B
├─ private-a  us-east-1a   10.0.3.0/24    app servers / EKS nodes
├─ private-b  us-east-1b   10.0.4.0/24    app servers / EKS nodes
├─ data-a     us-east-1a   10.0.5.0/24    RDS primary
└─ data-b     us-east-1b   10.0.6.0/24    RDS standby
Each /24 = 256 addresses; AWS reserves 5 per subnet → 251 usable.
Room to grow: 10.0.7.0 – 10.0.255.255 is still free.

Example 2 – The whole VPC as code (open-source Terraform AWS VPC module; works with OpenTofu)

module "vpc" {
  source  = "terraform-aws-modules/vpc/aws"
  version = "~> 5.0"

  name = "campus-jobs"
  cidr = "10.0.0.0/16"

  azs              = ["us-east-1a", "us-east-1b"]
  public_subnets   = ["10.0.1.0/24", "10.0.2.0/24"]
  private_subnets  = ["10.0.3.0/24", "10.0.4.0/24"]
  database_subnets = ["10.0.5.0/24", "10.0.6.0/24"]

  enable_nat_gateway     = true
  one_nat_gateway_per_az = true   # survives the loss of one zone
  enable_dns_hostnames   = true

  enable_flow_log                      = true
  create_flow_log_cloudwatch_log_group = true
  create_flow_log_cloudwatch_iam_role  = true
}

Example 3 – Security groups chained tier by tier

resource "aws_security_group" "alb" {
  name   = "alb-sg"
  vpc_id = module.vpc.vpc_id
  ingress {
    description = "HTTPS from the internet"
    from_port   = 443
    to_port     = 443
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }
  egress {
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks = ["0.0.0.0/0"]
  }
}

resource "aws_security_group" "app" {
  name   = "app-sg"
  vpc_id = module.vpc.vpc_id
  ingress {
    description     = "App port, only from the load balancer"
    from_port       = 8080
    to_port         = 8080
    protocol        = "tcp"
    security_groups = [aws_security_group.alb.id]
  }
  egress {
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks = ["0.0.0.0/0"]
  }
}

resource "aws_security_group" "db" {
  name   = "db-sg"
  vpc_id = module.vpc.vpc_id
  ingress {
    description     = "PostgreSQL, only from the app servers"
    from_port       = 5432
    to_port         = 5432
    protocol        = "tcp"
    security_groups = [aws_security_group.app.id]
  }
}

Example 4 – Inspect the network with the AWS CLI

aws ec2 describe-vpcs --filters Name=tag:Name,Values=campus-jobs
aws ec2 describe-subnets --filters Name=vpc-id,Values=vpc-0abc123 \
  --query "Subnets[].[CidrBlock,AvailabilityZone,MapPublicIpOnLaunch]" --output table
aws ec2 describe-route-tables --filters Name=vpc-id,Values=vpc-0abc123 \
  --query "RouteTables[].Routes[]" --output table
aws ssm start-session --target i-0abc123def4567890   # shell access with no open ports

Hands-on lab

Build and test the campus-jobs VPC

Using an AWS Free Tier account, you build the network, prove each security rule works, and clean up so nothing keeps costing money.

  • Create the VPC with the console “VPC and more” wizard, then again with Terraform/OpenTofu
  • Launch a small instance in a private subnet and connect with Session Manager
  • Prove outbound internet works through the NAT gateway – and inbound does not
  • Add security groups for ALB → app → database and test each hop
  • Add an S3 gateway endpoint and confirm S3 traffic no longer uses the NAT gateway
  • Enable flow logs and find a REJECTED connection attempt
  • Delete NAT gateways, Elastic IPs and instances at the end (they are billed hourly)

Key terms

Vocabulary to master

  • VPC
  • CIDR
  • Subnet
  • Availability zone
  • Public subnet
  • Private subnet
  • Internet Gateway
  • NAT gateway
  • Elastic IP
  • Route table
  • Security group
  • Network ACL
  • Stateful
  • Stateless
  • Bastion host
  • Session Manager
  • Site-to-site VPN
  • Direct Connect
  • Transit Gateway
  • VPC endpoint
  • PrivateLink
  • Flow logs

Check your understanding

Course quiz

Score 70% or more on every quiz to complete the course and unlock your certificate on My progress.

Further learning

Free official documentation & open-source references

Primary sources and free hands-on resources to go deeper.

Want to learn this with a mentor?

Join the Epitomsoft Academy Cloud & DevOps track: live sessions, real projects and career support.