AWS from Zero to Production — Phase 3, Part 4 of 5 · See the full series roadmap
Your app runs in us-east-1. A user in Sydney opens it.
Every image, every script, every API call crosses the Pacific Ocean. The page takes four seconds to load. Meanwhile, a bot in another country is hammering your login endpoint, and your DNS still points at a server you shut down last week.
All three problems live at the edge — the layer between users and your infrastructure. AWS gives you four services for it:
- Amazon Route 53 — DNS: how users find you
- Amazon CloudFront — content delivery: how your app loads fast everywhere
- AWS WAF — web application firewall: which requests get through
- AWS Shield — DDoS protection: staying up under attack
What you’ll walk away with
- 📖 Route 53 hosted zones, records, and alias records
- 🔀 Routing policies and health checks
- 🌍 How CloudFront caches content at the edge
- 🔒 Origin Access Control and signed URLs
- 🧱 AWS WAF rules and AWS Shield
Amazon Route 53
Route 53 is AWS’s DNS service. It also registers domains and runs health checks.
Hosted zones
A hosted zone is a container for the DNS records of one domain.
- Public hosted zones answer queries from the internet, such as
example.com. - Private hosted zones answer queries only from VPCs you associate with them, such as
internal.example.com. They’re perfect for internal service names.
Cost note: Each hosted zone has a small monthly charge, plus a charge per million queries. Check current Route 53 pricing.
DNS records
The record types you’ll use most:
- A — name to IPv4 address
- AAAA — name to IPv6 address
- CNAME — name to another name (not allowed at the zone apex, like
example.com) - MX — mail servers
- TXT — verification and policies, such as SPF
- NS and SOA — created automatically for the zone
Alias records: Route 53’s secret weapon
An alias record is a Route 53 extension that points a name directly to an AWS resource: a load balancer, a CloudFront distribution, an S3 website endpoint, or an API Gateway.
Why aliases beat CNAMEs for AWS targets:
- They work at the zone apex (
example.com), where CNAMEs can’t. - Route 53 tracks the target’s IP addresses automatically.
- Queries to alias records pointing at AWS resources are free.
example.com A (alias) -> my-alb-123.us-east-1.elb.amazonaws.com
www.example.com A (alias) -> d111111abcdef8.cloudfront.net
Routing policies
A routing policy decides how Route 53 answers a query:
- Simple: one answer. The default.
- Weighted: split traffic by percentage, for example 90% to v1 and 10% to v2. Great for gradual rollouts.
- Latency-based: send users to the Region with the lowest latency for them.
- Failover: send traffic to a primary, and switch to a secondary when the primary’s health check fails.
- Geolocation: answer based on the user’s country or continent — for content rights or data residency.
- Geoproximity: route by distance, with a bias to shift more or less traffic to a location.
- Multivalue answer: return up to eight healthy records at random — basic client-side load spreading.
- IP-based: route based on the client’s IP range.
Health checks
Route 53 health checks monitor an endpoint’s health — typically by requesting a URL — and mark it healthy or unhealthy. Routing policies then skip unhealthy records.
app.example.com failover PRIMARY -> ALB in us-east-1 (health check)
app.example.com failover SECONDARY -> ALB in us-west-2
If the primary fails its health check, Route 53 starts answering with the secondary. That’s DNS-level disaster recovery — we’ll use it in Phase 10.
Watch out: Failover is only as fast as clients’ DNS caches. Use short TTLs on failover records.
Amazon CloudFront
CloudFront is AWS’s content delivery network (CDN). It serves content from a global network of edge locations, close to users.
User in Sydney
|
v
CloudFront edge (Sydney) --- cache hit? return immediately
|
| cache miss
v
Origin in us-east-1 (S3 bucket, load balancer, API)
Key concepts
- Distribution: your CloudFront configuration, with a domain like
d111111abcdef8.cloudfront.net. - Origin: where content really lives: an S3 bucket, an Application Load Balancer, or any HTTP server.
- Cache behavior: rules for a path pattern, such as
/images/*or/api/*— which origin to use, how to cache, and which HTTP methods are allowed. - Cache policy: what’s included in the cache key (headers, cookies, query strings) and how long objects stay cached.
- Origin request policy: what’s forwarded to the origin, without affecting the cache key.
- Invalidation: remove objects from the cache before they expire.
A typical setup
Path pattern Origin Caching
/static/* S3 bucket cache for a long time
/api/* ALB caching disabled, all headers forwarded
default (*) S3 bucket cache for a short time
Engineer’s note: Use versioned file names (like
app.3f9a2c.js) for static assets and cache them for a long time. Then you rarely need invalidations, and deployments are instant.
CloudFront also terminates HTTPS at the edge. Use an ACM certificate requested in us-east-1 for your custom domain.
Origin Access Control: keep the bucket private
If CloudFront serves files from S3, you don’t want users bypassing CloudFront and hitting the bucket directly.
Origin Access Control (OAC) lets CloudFront sign its requests to S3, so the bucket can stay completely private:
- Create an OAC and attach it to the S3 origin.
- Keep Block Public Access on.
- Add a bucket policy that allows only your distribution:
{
"Effect": "Allow",
"Principal": { "Service": "cloudfront.amazonaws.com" },
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::my-site-bucket/*",
"Condition": {
"StringEquals": {
"AWS:SourceArn": "arn:aws:cloudfront::111122223333:distribution/EDFDVBD6EXAMPLE"
}
}
}
Note: OAC replaces the older Origin Access Identity (OAI). Use OAC for new distributions.
Signed URLs and signed cookies
Some content should be available only to specific users — paid videos, private reports, or downloads.
- Signed URLs grant access to one file for a limited time.
- Signed cookies grant access to many files, such as everything under
/premium/*.
Your app signs them with a private key whose public key is registered in a CloudFront key group. CloudFront checks the signature and expiry before serving the file.
Don’t confuse them: CloudFront signed URLs protect content through CloudFront. S3 presigned URLs grant temporary access directly to S3. Phase 5 covers presigned URLs.
AWS WAF: filter bad requests
AWS WAF is a web application firewall. It inspects HTTP requests and allows, blocks, counts, or challenges them based on rules.
Attach a web ACL to CloudFront, an Application Load Balancer, API Gateway, and other supported services.
Common rules:
- AWS Managed Rules: ready-made rule groups for common threats, such as the OWASP Top 10, known bad inputs, and SQL injection.
- Rate-based rules: block an IP that sends too many requests, for example to a login endpoint.
- IP sets: allow or block specific address ranges.
- Geo match: block or allow by country.
- Bot Control: a paid managed rule group for detecting bots.
Engineer’s note: Deploy new rules in Count mode first. Watch what they’d block for a few days, then switch to Block. That’s how you avoid blocking real customers.
AWS Shield: DDoS protection
A distributed denial-of-service (DDoS) attack floods you with traffic until you go down.
- AWS Shield Standard is automatic and free for all AWS customers. It protects against common network and transport layer attacks.
- AWS Shield Advanced is a paid subscription with enhanced detection, 24/7 access to the AWS Shield Response Team, and cost protection for scaling charges caused by an attack.
Putting CloudFront and Route 53 in front of your app already helps, because AWS’s edge network absorbs much of the attack traffic before it reaches your Region.
The edge, all together
User
|
v
Route 53 (alias) -> app.example.com resolves to CloudFront
|
v
CloudFront + WAF -> HTTPS, caching, request filtering
| (Shield Standard on by default)
+--> /static/* -> S3 bucket (private, OAC)
|
+--> /api/* -> Application Load Balancer -> app in private subnets
That’s a production-grade front door — and every piece is managed for you.
Common mistakes
- Using a CNAME at the zone apex. Use an alias record.
- Long TTLs on records you might need to fail over.
- A public S3 bucket behind CloudFront. Use OAC and keep the bucket private.
- Requesting the CloudFront certificate outside
us-east-1. - Caching API responses that vary by user, and serving one user’s data to another. Be deliberate about the cache key.
- Turning WAF rules straight to Block without testing in Count mode.
Key takeaways
- Route 53 hosted zones hold records; alias records point to AWS resources, even at the apex.
- Routing policies plus health checks enable weighted rollouts, latency routing, and failover.
- CloudFront caches content at the edge; cache behaviors route paths to different origins.
- Origin Access Control keeps S3 origins private.
- AWS WAF filters requests; Shield Standard protects every account against common DDoS attacks.
Quick self-check
Test yourself before moving on:
- Why use an alias record instead of a CNAME for
example.com? - Which routing policy sends 10% of traffic to a new version?
- How do you stop users from bypassing CloudFront and reading S3 directly?
- Do you have to pay for basic DDoS protection on AWS?
Answers
- CNAMEs aren’t allowed at the zone apex; aliases are, and they’re free for AWS targets.
- Weighted routing.
- Origin Access Control, a private bucket, and a bucket policy limited to the distribution.
- No. AWS Shield Standard is automatic and free.
What’s next
In Part 5, it’s time to build. You’ll create a two-AZ VPC from scratch, put an Application Load Balancer in public subnets, run app servers in private subnets, and prepare isolated database subnets.
Do you put CloudFront in front of your APIs, or only static files? Share your setup in the comments.