Custom Domains, Edge Security & Best Practices

Use your own domain with HTTPS, protect your site at the edge, and keep costs down.

1 min read

Custom domain + HTTPS

  1. Request a free certificate in AWS Certificate Manager (ACM), in the us-east-1 Region. CloudFront only uses certificates from us-east-1.
  2. Add your domain (e.g. www.notesnap.app) as an alternate domain name on the distribution and select the certificate.
  3. In Route 53, create an alias record pointing your domain at the distribution.
  4. Set the viewer protocol policy to Redirect HTTP to HTTPS.

Security at the edge

  • AWS Shield Standard (DDoS protection) is included automatically.
  • AWS WAF can block common attacks, bad bots, and abusive IPs before they reach your origin.
  • Signed URLs or cookies restrict premium content to paying users.
  • CloudFront Functions run lightweight JavaScript on every request (redirects, header changes). Lambda@Edge handles heavier logic.

Best practices

  • Turn on compression (gzip/Brotli) for text assets.
  • Use separate behaviors for static files (long TTL) and APIs (no caching, or short TTL).
  • Watch the cache hit ratio in CloudFront reports. If it's low, check your cache keys.
  • Prefer hashed filenames to frequent invalidations.
Watch out

The ACM certificate must be in us-east-1 for CloudFront, even if everything else is in another Region. It's a very common stumbling block.

Key takeaways

  • CloudFront certificates come from ACM in us-east-1, and Route 53 alias records point your domain at it.
  • Shield Standard is automatic, and WAF, signed URLs, and edge functions add more control.
  • Compress, split behaviors, and monitor your cache hit ratio.

Check your understanding

Pick an answer to see the explanation.

  1. 1. Your ACM certificate in eu-west-1 doesn't show up in CloudFront. Why?

Next in “Run a classic web app”
You finished CloudFront. Continue with the CloudFormation & CDK tutorial