AWS VPC and Networking

The security group against network ACL table is the single most tested comparison in AWS networking, because the stateful and stateless difference explains most blocked-traffic scenarios.

Security groups against network ACLs

PropertySecurity groupNetwork ACL
Applies toInstance or ENISubnet
StateStateful. Return traffic allowed automaticallyStateless. Return traffic needs its own rule
RulesAllow onlyAllow and deny
EvaluationAll rules evaluated, any allow winsIn rule number order, first match wins
Default inboundDeny everythingDefault ACL allows everything
Common mistakeForgetting the security group on the targetBlocking ephemeral return ports 1024 to 65535

VPC components

ComponentWhat it does
VPCAn isolated network in one region. CIDR /16 to /28
SubnetA range in one availability zone. AWS reserves five addresses
Public subnetHas a route to an internet gateway
Private subnetNo route to an internet gateway
Internet gatewayTwo-way internet access for the VPC
NAT gatewayOutbound only, for private subnets. Managed, per-AZ
Egress-only internet gatewayThe IPv6 equivalent of a NAT gateway
Route tableWhere traffic goes. One per subnet association
VPC endpoint (gateway)Private access to S3 and DynamoDB, free
VPC endpoint (interface)Private access to most other services, via PrivateLink

Connecting outside the VPC

RequirementOption
Connect two VPCsVPC peering. Non-transitive, no overlapping CIDRs
Connect many VPCs and on-premisesTransit Gateway
On-premises over the internetSite-to-site VPN
On-premises, private and consistentDirect Connect
Expose a service to another account privatelyPrivateLink
Global DNS routingRoute 53 with a routing policy

Route 53 routing policies

PolicyChooses by
SimpleOne record, no logic
WeightedA proportion you set
LatencyLowest latency to the client
FailoverPrimary while healthy, else secondary
GeolocationWhere the query came from
GeoproximityDistance, with a bias you can adjust
Multivalue answerSeveral healthy records at random

Now test yourself

Memorizing a table is a start. Practice questions are what make it stick, and every answer carries the full explanation.