ADR-0002: Serverless static hosting on AWS#
- Status: accepted
- Date: 2026-07-30
Context#
The product is a documentation website. The requirements were: as cheap as possible, serverless, on AWS, and able to showcase current infrastructure practice. It also needs to be a foundation for later experiments — a self-run DNS server, a DoH resolver — rather than a dead end.
Decision#
Private S3 bucket as origin, CloudFront as the edge, reached only via Origin Access Control with SigV4. ACM for certificates. Route 53 for DNS. A single Lambda Function URL for the one dynamic endpoint.
No VPC, no load balancer, no container runtime, no database.
Alternatives considered#
S3 static website endpoint alone. Requires a public bucket, serves HTTP only, cannot use OAC, and gives no control over response headers. It fails the security requirement outright and cannot serve a .dev domain at all, since the TLD is HSTS-preloaded and browsers refuse plaintext HTTP to it.
CloudFront with an S3 Origin Access Identity. Works, but OAI is legacy. OAC supersedes it, supports SigV4, works in every region, and supports SSE-KMS. No reason to use OAI in new work.
Amplify Hosting. Genuinely convenient, and it bundles CI/CD. Rejected because it abstracts away exactly the layer this project is meant to demonstrate — the CloudFront and DNS configuration would be Amplify's, not mine, and not inspectable as Terraform.
Lambda@Edge for the redirects and URL rewriting. Roughly six times the price of CloudFront Functions and needs a full Node runtime for work that is string manipulation. CloudFront Functions are the right size for the job.
API Gateway in front of the Lambda. Adds a per-request charge and a second service to configure, for a single unauthenticated read endpoint. A Function URL behind CloudFront, locked to OAC, does the same job.
Cloudflare Pages, or Netlify, or GitHub Pages. All cheaper or free, and Cloudflare's DNSSEC and ECH support is ahead of AWS's. Rejected because the stated goal was AWS, and because the free tiers hide the cost decisions that are part of what this project is demonstrating.
Consequences#
Positive: about $1.55/month. Nothing to patch. The perpetual CloudFront free tier makes traffic effectively free. Every layer is inspectable Terraform. Adding a second origin later — the DoH resolver — is an extra cache behaviour on a distribution that already exists.
Negative: more Terraform than a managed platform would need, and more opportunity to misconfigure something. CloudFront propagation makes each apply slow (mitigated by wait_for_deployment = false). Cache invalidation is a deploy-time concern that a platform would handle.
Neutral: the architecture is conventional for AWS static hosting. That is fine — the interesting parts are the DNS and TLS configuration on top of it.
Revisit when#
The site stops being static, or something needs a persistent listener. The DNS server on the roadmap is the first thing that genuinely breaks this model, and it is planned as a separate delegated subdomain precisely so it does not.