Course map

Topic 177 / Advanced

VPC and cloud networking: private endpoints, network boundaries

Chapter 11.1 · Cloud Fundamentals

What and why

IAM (→ 176) controls who can call an API; it says nothing about which network path a call takes to get there. A Virtual Private Cloud (VPC) is a logically isolated slice of the provider's network — your own address space, subnets, and routing — giving cloud resources the same kind of network boundary a physical datacenter's firewall once gave. Builds on: → 24 (IP addressing and routing).

Diagram

VPC
┌───────────────────────────────────────────┐
│ Public subnet:  [load balancer] ── internet gateway ── internet
│ Private subnet: [app servers] ── NAT gateway ── internet (outbound only)
│ Private subnet: [database]   ── private endpoint ── managed service
│                 (reachable only from the app servers' security group)
└───────────────────────────────────────────┘

How it works

  1. A VPC defines a private IP address range; subnets within it partition that range, each tied to one AZ (→ 175).
  2. Public subnets route to an internet gateway — reachable from and able to reach the public internet directly; private subnets have no such route.
  3. Resources that don't need to be internet-reachable (databases, internal services) belong in private subnets; only load balancers and bastion/gateway resources belong in public subnets.
  4. A NAT gateway lets private-subnet resources make outbound connections without being reachable from outside.
  5. Private endpoints connect a VPC directly to a managed service over the provider's internal network, so traffic to that service never traverses the public internet.
  6. Security groups (instance-level) and network ACLs (subnet-level) act as stateful/ stateless firewalls (→ 168) layered on top: routing decides what path exists, security groups decide what's allowed on it.
  7. Explicit network boundaries between environments (dev, staging, prod as separate VPCs or accounts) stop a staging misconfiguration or compromise from reaching production — the network-level analog of least privilege (→ 176).

Practical example

(numbers illustrative). A three-tier app places its load balancer in a public subnet, its application servers in a private subnet reachable only from the load balancer's security group, and its database in a private subnet reachable only from the application servers' security group, with a private endpoint to the provider's object storage. An attacker who compromises the public load balancer's host still cannot reach the database — its security group allows only the application tier's identity, not "anything in the VPC."

When to use it

  • Use private subnets for anything that doesn't need to be internet-reachable — default to private unless proven otherwise.
  • Use private endpoints for managed-service traffic whenever available — it removes a public-internet hop from the attack surface and is often lower-latency too.
  • Use separate VPCs or accounts per environment once more than one team or more than a hobby project is involved.
  • Avoid flat, single-subnet VPCs with everything public — convenient to start, expensive to unwind once something is compromised.
  • Failure scenarios: a database security group left open to the whole VPC (or the internet) "temporarily" for debugging and never closed; a private subnet's NAT gateway becoming a single point of failure for every outbound call it serves; environment boundaries blurred by a shared VPC across dev and prod, letting a staging bug reach production data.
  • Simpler alternative: for a single small service with no compliance requirement, the provider's default VPC with sane security groups is enough — custom subnet topology earns its complexity at a second or third service, or a compliance requirement.

Practice

(trace/design kind, 20–30 min, paper exercise). Diagram a VPC for a three-tier app (load balancer, app servers, database) across public/private subnets and two AZs, label the one legal path in and out of each resource, then answer: if the database's security group were accidentally opened to the whole VPC's address range, what's now reachable that shouldn't be? Done when every illegitimate path is named, not just the legitimate ones diagrammed.

Key takeaway

A VPC gives cloud resources the network boundaries a physical datacenter firewall once gave; private subnets and endpoints keep traffic off the public internet, and environment-level boundaries contain the blast radius of any one compromise. Done when you can: place a three-tier app's resources correctly across public/private subnets and explain every path in and out. Used next in → 178 (compute and storage sit inside this topology), → 182 (Kubernetes networking layers on top of it), → 191 (provider-specific names for these same pieces).

References

None — this topic makes no external claims.

Source directory

Search the guide