A CloudFront distribution config builder that produces the DistributionConfig JSON
document the AWS CLI and API expect. Choose an origin, set the cache behavior and security
policy, and copy a config you can feed straight into
aws cloudfront create-distribution. Nothing leaves your browser — no AWS keys required.
How it works
CloudFront distributions are defined by a single JSON structure. The builder assembles the
required pieces: an Origins block (with S3OriginConfig for buckets or CustomOriginConfig
with TLS settings for custom backends), a DefaultCacheBehavior carrying the viewer protocol
policy, allowed methods, and the three TTL values, plus optional CustomErrorResponses,
Restrictions.GeoRestriction, and a ViewerCertificate.
A unique CallerReference is generated from the current timestamp so AWS treats each apply
as idempotent — re-submitting the same reference will not create a duplicate distribution.
The TTL trio controls caching: MinTTL is the lower bound, DefaultTTL applies when the
origin sends no Cache-Control, and MaxTTL caps everything.
Tips and notes
- For a single-page app on S3, map error code
403to/index.htmlwith response code200so client-side routes resolve correctly instead of showing an access-denied page. PriceClass_100serves only North America and Europe edge locations and is the cheapest; raise it only if your audience is global and latency in Asia matters.- An S3 origin reached over the public website endpoint behaves differently from one reached through Origin Access Control. For private buckets, pair this with an OAC bucket policy.
- Set
Compressto true so CloudFront gzips or brotli-compresses text assets at the edge, shrinking transfer for CSS, JS, and HTML.