AWS Learning Journey

From Domain Name to Edge Cache: Route 53, CloudFront, WAF, and Shield

How users find your app, how it loads fast everywhere, and how you keep bots and attacks out — the AWS edge, explained.

8 min read · 1589 words
AWSCloudFrontDNSWeb SecurityCloud Computing
From Domain Name to Edge Cache: Route 53, CloudFront, WAF, and Shield cover image

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:

What you’ll walk away with


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.

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:

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:

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:

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

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:

  1. Create an OAC and attach it to the S3 origin.
  2. Keep Block Public Access on.
  3. 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.

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:

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.

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


Key takeaways


Quick self-check

Test yourself before moving on:

  1. Why use an alias record instead of a CNAME for example.com?
  2. Which routing policy sends 10% of traffic to a new version?
  3. How do you stop users from bypassing CloudFront and reading S3 directly?
  4. Do you have to pay for basic DDoS protection on AWS?

Answers

  1. CNAMEs aren’t allowed at the zone apex; aliases are, and they’re free for AWS targets.
  2. Weighted routing.
  3. Origin Access Control, a private bucket, and a bucket policy limited to the distribution.
  4. 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.


Share this article

LinkedIn post draft