If a website is just HTML, CSS, JavaScript and images, it does not need a server. Amazon S3 stores the files and CloudFront serves them from edge locations close to visitors, with HTTPS, caching and very little to maintain. It is one of the cheapest and most reliable ways to host a landing page, a documentation site or a single-page application on AWS.
This guide walks through a production-ready setup with a private bucket, Origin Access Control, a free certificate and your own domain.
Why S3 and CloudFront
S3 is durable object storage that can hold any number of files. CloudFront is AWS’s content delivery network, with edge locations around the world. Together they give a static site global speed, HTTPS, protection from many attacks at the edge, and no servers to patch. AWS documents S3 hosting in the S3 user guide and the private-bucket pattern in the CloudFront developer guide.

Website endpoint vs CloudFront
| Feature | S3 website endpoint alone | CloudFront with private bucket |
|---|---|---|
| HTTPS | No | Yes, free ACM certificate |
| Bucket access | Must be public | Private, Origin Access Control |
| Global caching | No | Yes |
| Custom error pages | Basic | Per status code |
| Free monthly transfer | Part of 100 GB AWS allowance | 1 TB on CloudFront free tier |
Create the bucket
- Create an S3 bucket in a Region near you. The name does not have to match the domain when CloudFront is in front.
- Leave Block all public access turned on and keep default encryption.
- Do not enable S3 static website hosting; CloudFront will use the bucket’s REST endpoint.
- Upload the site so index.html sits at the root, with assets in folders.
The S3 vs EBS vs EFS guide explains why object storage is the right home for static files.
Create the distribution
- In CloudFront, create a distribution and choose the S3 bucket as the origin.
- Under origin access, select Origin access control settings and create a new OAC.
- Copy the bucket policy that CloudFront offers and add it to the bucket. It allows only this distribution to read objects.
- Set the viewer protocol policy to redirect HTTP to HTTPS.
- Use the CachingOptimized policy for static files, and enable compression.
- Set the default root object to index.html.
Wait for the distribution to deploy, then open its cloudfront.net address to check the site.
Certificate and custom domain
- In AWS Certificate Manager, switch to US East (N. Virginia) and request a public certificate for example.com and www.example.com. CloudFront only uses certificates from this Region.
- Validate with DNS by adding the CNAME records ACM shows.
- Edit the distribution, add both names as alternate domain names, and select the certificate.
- In Route 53, create alias A and AAAA records pointing to the distribution. With another DNS provider, use a CNAME for www and the provider’s flattening or redirect for the apex.
Single-page applications
React, Vue and similar apps use client-side routing, so a direct visit to /pricing has no matching file. Add custom error responses that return /index.html with status 200 for 403 and 404 errors, or use a small CloudFront Function to rewrite paths. For multi-page static sites, a CloudFront Function can also append index.html to folder paths.
Deploying updates
Upload new files with the AWS CLI using aws s3 sync and the –delete option, then invalidate changed paths. Better still, give CSS and JavaScript versioned file names and cache them for a long time, and keep HTML on a short cache so only small files need invalidating. The AWS CLI setup guide covers safe credentials for deploy scripts, and a CI pipeline can do the same with an IAM role.
What it costs
A small site often costs little more than a domain. You pay for S3 storage and requests, and CloudFront delivery beyond its always-free allowance of 1 TB of transfer and 10 million requests a month. Transfer from S3 to CloudFront is free. AWS also offers flat-rate CloudFront plans, including a free plan, if you prefer a fixed monthly price. The data transfer costs guide explains why CloudFront usually lowers the bill.
Many people run several static sites from one account. If you need a separate account for client projects, the verification and billing details listed with each AWS account show what is ready to use.
What this setup cannot do
- Run server-side code such as PHP, so no WordPress; use Lightsail or EC2, as the Lightsail vs EC2 guide explains.
- Process forms on its own; add an API with Lambda or a third-party form service.
- Store user data; use a database service behind an API.
S3 and CloudFront hosting questions
Can I host a website on S3 without CloudFront?
Yes, S3 static website hosting works on its own, but the website endpoint only supports HTTP and the bucket must be public. CloudFront adds HTTPS, caching and lets the bucket stay private.
Which Region must the ACM certificate be in?
For CloudFront, the certificate must be requested or imported in US East (N. Virginia), us-east-1, whatever Region your bucket is in.
What is Origin Access Control?
Origin Access Control (OAC) lets CloudFront sign its requests to S3 so the bucket policy can allow only that distribution. It replaces the older Origin Access Identity and supports more features such as SSE-KMS.
How do I make changes appear immediately?
Either create an invalidation for the changed paths or use versioned file names for assets. The first 1,000 invalidation paths each month are free.
Can S3 and CloudFront host WordPress?
No. S3 serves static files only and cannot run PHP or a database. WordPress needs a server such as Lightsail or EC2, though CloudFront can still sit in front of it.
Editorial guide by Mark Biden · Reviewed 24 November 2026. Official sources are linked beside the relevant sections; AWS features, quotas and prices change, so confirm details in the AWS console before relying on them.

Leave a Reply