Serve Globally with CloudFront
CloudFront is AWS's CDN β it caches your site at edge locations worldwide for speed and HTTPS.
CloudFront is a Content Delivery Network. It copies your files to hundreds of edge locations around the world, so a user in Tokyo is served from Tokyo, not your one bucket in Virginia.
Why put CloudFront in front of S3?
- HTTPS on your custom domain via ACM.
- Caching makes repeat loads near-instant.
- Origin Access Control keeps the bucket private.
Example
{
"Comment": "myapp production site",
"DefaultRootObject": "index.html",
"Origins": [{
"Id": "s3-origin",
"DomainName": "myapp-prod-web-2026.s3.us-east-1.amazonaws.com",
"OriginAccessControlId": "E1EXAMPLE123"
}],
"DefaultCacheBehavior": {
"TargetOriginId": "s3-origin",
"ViewerProtocolPolicy": "redirect-to-https"
}
}When to use it
- A global SaaS product uses CloudFront so users in Tokyo get cached assets from a nearby edge location instead of hitting a US-East S3 bucket.
- A media company serves video thumbnails through CloudFront to handle traffic spikes without overwhelming the origin.
- A developer enables HTTPS on an S3 static site by putting a CloudFront distribution in front of it.
More examples
Create CloudFront distribution for S3
Creates a CloudFront distribution that pulls content from an S3 website endpoint and caches it globally.
aws cloudfront create-distribution \
--origin-domain-name my-site-bucket.s3-website-us-east-1.amazonaws.com \
--default-root-object index.htmlCloudFront distribution config snippet
Shows the key parts of a CloudFront distribution config: locked-down S3 origin with OAI and HTTPS redirect.
{
"Origins": {
"Quantity": 1,
"Items": [{
"Id": "S3Origin",
"DomainName": "my-site-bucket.s3.amazonaws.com",
"S3OriginConfig": { "OriginAccessIdentity": "origin-access-identity/cloudfront/ABCDEF" }
}]
},
"DefaultCacheBehavior": {
"ViewerProtocolPolicy": "redirect-to-https",
"Compress": true
}
}Get distribution domain name
Lists all distributions with their domain names so you can verify the distribution is deployed.
# Retrieve the CloudFront domain after creation
aws cloudfront list-distributions \
--query 'DistributionList.Items[*].[Id,DomainName,Status]' \
--output table
Discussion