AWS Networking Deep Dive
Direct Connect, VPN, Route 53, CloudFront, Global Accelerator, ELB, and PrivateLink
On-premises ──── Direct Connect (1/10/100 Gbps) ────┐ └── Site-to-Site VPN (IPSec over internet) ──┤ │ AWS Region │ ┌─────────────────┘ │ VPC │ Transit Gateway │ VPC Endpoints └──────────────────────────────┐ │ Internet ──── Route 53 (DNS) ──── CloudFront (CDN) ──── ALB/NLB ──── EC2/ECS/Lambda └── Global Accelerator (Anycast) ────────────────────────────┘
Direct ConnectHybrid

AWS Direct Connect provides dedicated, private network connections from on-premises to AWS, bypassing the public internet. It offers consistent latency and can be used for compliance requirements.

Connection types

TypeSpeedHow to get
Dedicated connection1, 10, 100 GbpsOrder directly from AWS. Physical port at a DX location. Takes weeks to provision.
Hosted connection50 Mbps – 10 GbpsOrdered via a DX partner who shares their dedicated port. Faster provisioning.

Virtual Interfaces (VIFs)

VIF TypeConnects toUse case
Private VIFVPC (via VGW or TGW)Access resources in a single VPC using private IPs
Transit VIFDirect Connect Gateway → Transit GatewayAccess multiple VPCs/regions via a single connection
Public VIFAWS public services (S3, DynamoDB, SQS…)Reach AWS public endpoints over private path — bypasses internet

Resiliency models

Design
Maximum resiliency (recommended for critical workloads):
  ├── DX Location A — Connection 1 → VGW/TGW
  ├── DX Location A — Connection 2 → VGW/TGW
  ├── DX Location B — Connection 3 → VGW/TGW
  └── DX Location B — Connection 4 → VGW/TGW

High resiliency:
  ├── DX Location A — Connection 1 → VGW/TGW
  └── DX Location B — Connection 2 → VGW/TGW

Development (non-critical only):
  └── DX Location A — Connection 1 + VPN backup → VGW/TGW
DX + VPN backup. A common pattern is to use Direct Connect as the primary path and an IPSec VPN as the failover. BGP communities and route preferences control which path is preferred.
Site-to-Site VPNHybrid

AWS Site-to-Site VPN creates encrypted IPSec tunnels between your on-premises network and an AWS VPC over the public internet. Each VPN connection has two tunnels for redundancy.

Components

ComponentDescription
Virtual Private Gateway (VGW)AWS-side VPN concentrator attached to a VPC. Supports BGP and static routing.
Transit Gateway (TGW)Alternative to VGW — attach VPN to TGW for hub-and-spoke to multiple VPCs.
Customer Gateway (CGW)AWS resource representing your on-premises VPN device. Contains its public IP and BGP ASN.
VPN ConnectionThe actual IPSec connection between VGW/TGW and CGW. Two tunnels, each to different AWS endpoints.
Shell
# Create customer gateway
aws ec2 create-customer-gateway \
  --type ipsec.1 \
  --public-ip 203.0.113.10 \
  --bgp-asn 65000

# Create VPN connection (BGP)
aws ec2 create-vpn-connection \
  --type ipsec.1 \
  --customer-gateway-id cgw-0abc123 \
  --vpn-gateway-id vgw-0abc123 \
  --options TunnelOptions='[{PreSharedKey=mysecret1},{PreSharedKey=mysecret2}]'

# Download configuration for your device type
aws ec2 get-vpn-connection-device-sample-configuration \
  --vpn-connection-id vpn-0abc123 \
  --vpn-connection-device-type-id 5fb390ba

# Check tunnel status
aws ec2 describe-vpn-connections \
  --vpn-connection-ids vpn-0abc123 \
  --query 'VpnConnections[*].VgwTelemetry'

Accelerated VPN

Accelerated Site-to-Site VPN routes traffic through AWS Global Accelerator edge locations to reduce latency and improve reliability. Requires a TGW attachment; not available with VGW.
Route 53DNS

Route 53 is AWS's authoritative DNS service. It supports public and private hosted zones, health checks, and multiple routing policies for traffic management.

Record types

TypeUse
AIPv4 address. Use Alias for AWS resources (ELB, CloudFront, S3, API GW).
AAAAIPv6 address.
CNAMECanonical name. Cannot be used at zone apex (use Alias instead).
AliasRoute 53 extension — points to AWS resources. Free queries, works at apex, follows IP changes.
MXMail exchange.
TXTText records — SPF, DKIM, domain verification.
NSName server records — delegation.
SRVService location — port and priority.

Routing policies

PolicyBehaviourUse case
SimpleReturns all values; client picks randomlySingle resource, no health checks
WeightedDistributes traffic by weight (0–255)Blue/green deployments, canary releases
LatencyReturns record from region with lowest RTT for the clientMulti-region active-active
FailoverPrimary record; health-checked. Falls back to secondary if unhealthy.Active-passive DR
GeolocationRoutes based on client's geographic location (continent/country)Data residency, regional content
GeoproximityRoutes based on distance with configurable biasShift traffic toward/away from a region
Multi-value answerReturns up to 8 healthy records randomlySimple client-side load balancing
IP-basedRoutes based on client IP CIDR blocksRoute ISP traffic to specific endpoints
Shell
# Create a private hosted zone
aws route53 create-hosted-zone \
  --name corp.internal \
  --vpc VPCRegion=us-east-1,VPCId=vpc-0abc123 \
  --caller-reference $(date +%s)

# Upsert a weighted record (blue/green)
aws route53 change-resource-record-sets \
  --hosted-zone-id Z1234 \
  --change-batch '{
    "Changes": [{
      "Action": "UPSERT",
      "ResourceRecordSet": {
        "Name": "api.example.com",
        "Type": "A",
        "SetIdentifier": "blue",
        "Weight": 90,
        "AliasTarget": {
          "DNSName": "blue-alb.us-east-1.elb.amazonaws.com",
          "EvaluateTargetHealth": true,
          "HostedZoneId": "Z35SXDOTRQ7X7K"
        }
      }
    }]
  }'

# Health check
aws route53 create-health-check \
  --caller-reference $(date +%s) \
  --health-check-config Type=HTTPS,FullyQualifiedDomainName=api.example.com,Port=443,ResourcePath=/health
CloudFrontCDN

CloudFront is AWS's global CDN with 450+ Points of Presence. It caches content at the edge, terminates TLS, and can run code at the edge via Lambda@Edge and CloudFront Functions.

Key concepts

ConceptDescription
DistributionA CloudFront deployment with one or more origins and cache behaviours.
OriginThe source of content: S3 bucket, ALB, API Gateway, custom HTTP origin, or origin group.
Cache behaviourRules matching URL path patterns to origins, with cache policies and TTLs. Default (*) is required.
Cache policyControls what's included in the cache key (headers, cookies, query strings) and TTLs.
Origin request policyControls what CloudFront forwards to the origin (separate from cache key).
OACOrigin Access Control — allows CloudFront to authenticate to private S3 buckets (replaces OAI).

Common patterns

Design
Static site (S3 + CloudFront + OAC):
  S3 bucket (no public access) ← OAC ← CloudFront ← users

API + static assets:
  /api/*  → ALB origin (no caching or short TTL)
  /*      → S3 origin (long TTL for versioned assets)

Multi-origin failover:
  Origin group: primary ALB + failover ALB
  Triggers on HTTP 5xx or 4xx from primary
Shell
# Invalidate cached paths
aws cloudfront create-invalidation \
  --distribution-id E1ABCDEF \
  --paths "/index.html" "/assets/*"

# Check distribution status
aws cloudfront get-distribution \
  --id E1ABCDEF \
  --query 'Distribution.{Status:Status,Domain:DomainName}'

# Enable real-time logs
aws cloudfront create-realtime-log-config \
  --end-points StreamType=Kinesis,KinesisStreamConfig={RoleARN=arn:...,StreamARN=arn:...} \
  --fields timestamp c-ip sc-status cs-uri-stem time-taken \
  --name my-realtime-logs \
  --sampling-rate 100

Lambda@Edge vs CloudFront Functions

CloudFront FunctionsLambda@Edge
RuntimeJS (ECMAScript 5.1)Node.js, Python
Max execution1ms5s (viewer), 30s (origin)
Max memory2MB128MB–10GB
TriggersViewer request/responseViewer + origin request/response
Network accessNoYes
Use caseURL rewrites, header manipulation, simple authA/B testing, SSR, auth with external calls
Global AcceleratorGlobal

Global Accelerator provides two static anycast IP addresses that route user traffic to the nearest AWS edge location, then via the AWS backbone to the endpoint — reducing latency and improving availability.

CloudFront vs Global Accelerator

CloudFrontGlobal Accelerator
ProtocolHTTP/HTTPS onlyTCP, UDP (any port)
CachingYes — content cached at edgeNo — traffic routed, not cached
Use caseWeb content, APIs, mediaNon-HTTP (gaming, IoT, VoIP), static IPs needed
IP addressesChanges (use DNS)2 static anycast IPs — whitelistable
Health checksOrigin failover per distributionAutomatic failover across endpoint groups
Shell
# Create accelerator
aws globalaccelerator create-accelerator \
  --name my-app \
  --ip-address-type IPV4 \
  --enabled

# Add listener (port 443)
aws globalaccelerator create-listener \
  --accelerator-arn arn:aws:globalaccelerator::123456789:accelerator/xxx \
  --protocol TCP \
  --port-ranges FromPort=443,ToPort=443

# Add endpoint groups per region
aws globalaccelerator create-endpoint-group \
  --listener-arn arn:aws:globalaccelerator::... \
  --endpoint-group-region us-east-1 \
  --traffic-dial-percentage 100 \
  --endpoint-configurations EndpointId=arn:aws:elasticloadbalancing:...,Weight=100
Elastic Load BalancingLoad Balancing

AWS offers three load balancer types, each optimised for different use cases and protocols.

ALB vs NLB vs GWLB

ALBNLBGWLB
Layer7 (HTTP/HTTPS/gRPC/WebSocket)4 (TCP/UDP/TLS)3/4 (GENEVE)
RoutingPath, host, header, query, IP, methodPort-basedAll traffic to appliances
Static IPNo (use Global Accelerator)Yes — per-AZ static IPsN/A
TLS terminationYes + SNIYes (TLS passthrough also)No
Use caseHTTP APIs, microservices, web appsTCP apps, static IP, ultra-low latencyFirewalls, IDS/IPS, packet inspection

ALB routing rules

Shell
# Create ALB
aws elbv2 create-load-balancer \
  --name my-alb \
  --type application \
  --subnets subnet-public-1a subnet-public-1b \
  --security-groups sg-alb

# Create HTTPS listener with certificate
aws elbv2 create-listener \
  --load-balancer-arn arn:aws:elasticloadbalancing:... \
  --protocol HTTPS --port 443 \
  --certificates CertificateArn=arn:aws:acm:... \
  --default-actions Type=forward,TargetGroupArn=arn:aws:elasticloadbalancing:...

# Add path-based routing rule
aws elbv2 create-rule \
  --listener-arn arn:aws:elasticloadbalancing:... \
  --priority 10 \
  --conditions Field=path-pattern,Values="/api/*" \
  --actions Type=forward,TargetGroupArn=arn:aws:elasticloadbalancing:.../api-tg

# Enable access logs
aws elbv2 modify-load-balancer-attributes \
  --load-balancer-arn arn:... \
  --attributes Key=access_logs.s3.enabled,Value=true \
               Key=access_logs.s3.bucket,Value=my-alb-logs
Cheat SheetReference

Hybrid connectivity decision tree

Decision
Need private connectivity to AWS?
  ├── Consistent SLA, high bandwidth, low latency → Direct Connect
  │     ├── Single VPC → Private VIF + VGW
  │     └── Multiple VPCs/regions → Transit VIF + DXGW + TGW
  └── Quick setup, cost-sensitive, internet OK → Site-to-Site VPN
        └── Latency sensitive → Accelerated VPN (via TGW)

Exposing a service to consumers without VPC peering?
  └── PrivateLink (NLB-backed endpoint service)

Global traffic routing?
  ├── HTTP content, caching needed → CloudFront
  ├── Non-HTTP or static IP needed → Global Accelerator
  └── DNS-level routing (failover, geo, weighted) → Route 53

Direct Connect

Dedicated: 1/10/100 Gbps
Hosted: 50 Mbps–10 Gbps
VIF types: private, transit, public
Max resiliency: 2 locations × 2 connections

Route 53

Alias records — free, works at apex
Weighted for canary deploys
Latency for multi-region active-active
Failover with health checks for DR

CloudFront

OAC for private S3 origins
Invalidate: aws cloudfront create-invalidation
Functions for <1ms edge logic
Lambda@Edge for heavier processing

ELB

ALB: L7, path/host routing, HTTP
NLB: L4, static IP, TCP/UDP
GWLB: firewall/IDS appliances
Enable access logs to S3