← All posts

May 26, 2026

Multi-tenant SaaS on a single CloudFront distribution

How one distribution serves many partner brands on their own custom domains — clean URLs, per-tenant content, real TLS — without a distribution per customer.

awscloudfrontmulti-tenantsaas

When every customer wants their own domain, the naive answer is a CloudFront distribution per tenant. That doesn't scale — it's a cost and operational mess by the tenth customer. The better answer is one distribution that knows who's asking.

How the request flows

  • A viewer-request function reads the incoming host and looks it up in an edge key-value store.
  • The lookup returns a compact routing value — which tenant, which line of business, which build, which environment.
  • The function rewrites the origin path so the right static bundle answers, with no redirect and no tenant identifier leaking into the URL bar.

Content is fully data-driven: each tenant's site reads its own manifest, so a non-technical partner edits their site from an admin panel and the public page reflects it — no code change, no redeploy.

The hard part: certificates

Custom domains need real TLS. The trick that keeps it sane is a combined-SAN certificate covering the platform plus each attached domain, reissued and swapped automatically as new domains come online. One cert, many tenants, up to the provider's SAN ceiling — then you shard.

Production-grade by default: auth, monitoring, rollback, zero-downtime deploys — built in, not bolted on.

Got an app stuck on localhost?

I take products from localhost to live, monitored production — and don’t disappear after handoff.

Get in touch →