Network & Infrastructure Security

VPC Architecture & Network Segmentation

4 min read

Virtual Private Clouds (VPCs) are the foundation of cloud network security. Proper segmentation isolates workloads, limits blast radius, and implements defense in depth.

VPC Fundamentals Across Providers

ConceptAWS VPCAzure VNetGCP VPC
Network isolationVPCVirtual NetworkVPC Network
SubnetSubnet (AZ-bound)Subnet (region)Subnet (region)
Route tableRoute TableRoute TableRoutes
Internet accessInternet GatewayN/A (implicit)Cloud NAT
Private accessNAT GatewayNAT GatewayCloud NAT
PeeringVPC PeeringVNet PeeringVPC Peering

Secure VPC Architecture

Multi-Tier Architecture

┌─────────────────────────────────────────────────────────────┐
│                         VPC (10.0.0.0/16)                    │
├─────────────────────────────────────────────────────────────┤
│  Public Subnet (10.0.1.0/24)                                │
│  ┌─────────────────────────────────────────────────────┐    │
│  │  Load Balancer, NAT Gateway, Bastion Host           │    │
│  └─────────────────────────────────────────────────────┘    │
├─────────────────────────────────────────────────────────────┤
│  Private Subnet - Application (10.0.10.0/24)                │
│  ┌─────────────────────────────────────────────────────┐    │
│  │  Web Servers, API Servers, Application Layer        │    │
│  └─────────────────────────────────────────────────────┘    │
├─────────────────────────────────────────────────────────────┤
│  Private Subnet - Data (10.0.20.0/24)                       │
│  ┌─────────────────────────────────────────────────────┐    │
│  │  Databases, Cache, Data Stores                       │    │
│  └─────────────────────────────────────────────────────┘    │
└─────────────────────────────────────────────────────────────┘

AWS VPC Configuration

# Terraform - Secure VPC
resource "aws_vpc" "main" {
  cidr_block           = "10.0.0.0/16"
  enable_dns_hostnames = true
  enable_dns_support   = true

  tags = {
    Name = "production-vpc"
  }
}

# Public subnet
resource "aws_subnet" "public" {
  vpc_id                  = aws_vpc.main.id
  cidr_block              = "10.0.1.0/24"
  availability_zone       = "us-east-1a"
  map_public_ip_on_launch = false  # Never auto-assign public IPs

  tags = {
    Name = "public-subnet"
    Tier = "public"
  }
}

# Private subnet - no internet route
resource "aws_subnet" "private" {
  vpc_id            = aws_vpc.main.id
  cidr_block        = "10.0.10.0/24"
  availability_zone = "us-east-1a"

  tags = {
    Name = "private-subnet"
    Tier = "private"
  }
}

Azure VNet Configuration

# Create VNet with subnets
az network vnet create \
    --name production-vnet \
    --resource-group myRG \
    --address-prefix 10.0.0.0/16 \
    --subnet-name public-subnet \
    --subnet-prefix 10.0.1.0/24

# Add private subnet
az network vnet subnet create \
    --name private-subnet \
    --vnet-name production-vnet \
    --resource-group myRG \
    --address-prefix 10.0.10.0/24

GCP VPC Configuration

# Create custom VPC
gcloud compute networks create production-vpc \
    --subnet-mode=custom

# Create subnets
gcloud compute networks subnets create public-subnet \
    --network=production-vpc \
    --region=us-central1 \
    --range=10.0.1.0/24

gcloud compute networks subnets create private-subnet \
    --network=production-vpc \
    --region=us-central1 \
    --range=10.0.10.0/24 \
    --enable-private-ip-google-access

Network Segmentation Best Practices

Blast Radius Limitation

Each workload environment should be isolated:

EnvironmentVPC/VNetPeeringPurpose
Productionprod-vpcLimitedLive workloads
Stagingstaging-vpcTo prod (read-only)Pre-production testing
Developmentdev-vpcNoneDeveloper sandboxes
Shared Servicesshared-vpcHubDNS, logging, security

Micro-Segmentation

Beyond traditional network segmentation:

Traditional: Network → Subnet → Host
Cloud-native: Network → Subnet → Security Group → Application

Security groups provide application-level segmentation:

  • Web tier: Only accepts 443 from load balancer
  • App tier: Only accepts from web tier on specific port
  • Data tier: Only accepts from app tier on database port

VPC Flow Logs

Essential for network visibility:

# AWS - Enable VPC Flow Logs
aws ec2 create-flow-logs \
    --resource-type VPC \
    --resource-ids vpc-12345678 \
    --traffic-type ALL \
    --log-destination-type cloud-watch-logs \
    --log-group-name vpc-flow-logs

# Azure - Enable NSG Flow Logs
az network watcher flow-log create \
    --name myFlowLog \
    --nsg myNSG \
    --resource-group myRG \
    --storage-account myStorageAccount \
    --enabled true

# GCP - Enable VPC Flow Logs on subnet
gcloud compute networks subnets update private-subnet \
    --region=us-central1 \
    --enable-flow-logs

Private Connectivity

Keep traffic off the public internet:

ServiceAWSAzureGCP
StorageS3 Gateway EndpointPrivate EndpointPrivate Service Connect
DatabaseRDS via Interface EndpointPrivate EndpointPrivate Service Connect
APIsAPI Gateway PrivatePrivate EndpointPrivate Service Connect

Next, we'll configure security groups and NACLs for granular traffic control. :::

Quick check: how does this lesson land for you?

Quiz

Module 4: Network & Infrastructure Security

Take Quiz
FREE WEEKLY NEWSLETTER

Stay on the Nerd Track

One email per week — courses, deep dives, tools, and AI experiments.

No spam. Unsubscribe anytime.