In short
A portfolio, a college fest page or a React app's build folder doesn't need a server running all day. S3 can serve those files for a few rupees a month, and with CloudFront in front it gets HTTPS and speed too.
S3 can serve static websites (HTML, CSS, JavaScript and images) from a bucket website endpoint, which supports HTTP only. For HTTPS and a custom domain, the usual setup is CloudFront in front of a private bucket using origin access control.

Think of it like this
A notice board vs a reception desk
A server is like a reception desk with a staff member answering each question. A static site is a printed notice board: the same papers for everyone, no one needs to sit there. S3 is the board, and CloudFront is a network of copies of that board placed in every neighbourhood.
Watch it happen
Two ways to serve a static site from S3
S3 website endpoint
- Bucket's website hosting turned on
- HTTP only, no HTTPS
- Bucket must be public (BPA off, public read policy)
- Good for a quick demo
CloudFront + private bucket
- Bucket stays private, Block Public Access on
- Origin access control lets only CloudFront read
- HTTPS with a free ACM certificate and custom domain
- Cached at edge locations near users
Use the website endpoint to learn. For anything real, put CloudFront with origin access control in front of a private bucket.
The big ideas
What you need to know
Static means files
HTML, CSS, JavaScript and images. No server-side code like PHP or Node runs in S3.
Index and error documents
index.html is served for folder paths. An error document handles 404s, and SPAs often point it at index.html.
Website endpoint format
Like http://my-site.s3-website.ap-south-1.amazonaws.com. It differs from the normal REST endpoint.
Deploy with sync
aws s3 sync uploads only changed files. With CloudFront, create an invalidation if visitors need changes immediately.
See it in code
Walk through the code
1BUCKET=ananya-portfolio-20262 3aws s3 mb s3://$BUCKET --region ap-south-14aws s3 website s3://$BUCKET/ --index-document index.html --error-document 404.html5 6# Learning demo only: allow public reads on this bucket7aws s3api put-public-access-block --bucket $BUCKET \8 --public-access-block-configuration BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=false,RestrictPublicBuckets=false9aws s3api put-bucket-policy --bucket $BUCKET --policy '{10 "Version": "2012-10-17",11 "Statement": [{"Effect": "Allow", "Principal": "*",12 "Action": "s3:GetObject", "Resource": "arn:aws:s3:::'$BUCKET'/*"}]13}'14 15aws s3 sync ./dist s3://$BUCKET --delete16echo "http://$BUCKET.s3-website.ap-south-1.amazonaws.com"1/4Create the bucket and turn on website hosting with index and error pages.
A public website-endpoint demo in Mumbai. For a real site, keep BPA on and use CloudFront with origin access control instead.
Save yourself the pain
Common mistakes
Oops
Expecting https:// to work on the S3 website endpoint.
Do this instead
Website endpoints are HTTP only. Use CloudFront with an ACM certificate for HTTPS.
Oops
Making a bucket with private data public to host a site.
Do this instead
Use a separate bucket that holds only the public site files.
Your mission
Portfolio on S3
Quick check
You need HTTPS and a custom domain for a site whose files are in S3. What is the standard setup?
Go deeper
- 1Host a simple HTML page using the S3 website endpoint.
- 2Configure index and error documents and test a missing page.
- 3Read about CloudFront origin access control, which you will use in the project.
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.