CloudFront as the security edge
often confused with Exposing the origin directlyPutting CloudFront (or Global Accelerator for non-HTTP) in front of every internet-facing app, with AWS WAF and Shield on the edge, and locking the origin so it only accepts traffic from that edge.
- Requests land at hundreds of edge locations, so floods are spread out and absorbed; caching serves repeat requests without touching the origin.
- Shield Standard blocks common network-layer attacks automatically; WAF filters application-layer requests.
- Lock the origin: OAC for S3; for an ALB, allow only the
com.amazonaws.global.cloudfront.origin-facingmanaged prefix list in its security group, add a secret custom header checked by an ALB rule, or use a VPC origin so the ALB can stay private. - Use Route 53 (also Shield-protected) for DNS, and keep origins in private subnets where possible.
| Edge-first design | Origin exposed directly | |
|---|---|---|
| DDoS absorbed by | AWS global edge | Your ALB / instances |
| WAF location | On CloudFront, before your Region | On the ALB, in your Region |
| Bypass risk | None if origin is locked | n/a: origin is the front door |
| Latency | Lower (edge TLS, caching) | Higher for far users |
| Exam hint | “reduce attack surface”, “global users” | Rarely the best answer |
- Adding CloudFront but leaving the ALB or bucket publicly reachable: attackers skip the edge and hit the origin.
- Using an S3 website endpoint as origin and expecting OAC to work: website endpoints are custom origins and can’t use OAC.
- Relying only on security group IP lists of CloudFront: use the AWS-managed prefix list, which AWS keeps updated.
- Putting WAF only on the ALB when CloudFront is in front: that works, but blocking at the edge saves origin capacity.
- Forgetting non-HTTP apps: use Global Accelerator (also Shield-protected) instead of CloudFront.
- Public websites and APIs with global users.
- Absorbing DDoS before it reaches a Region.
- One place to apply WAF and TLS rules for many origins.