Day 52 โ How to Host a Static Website using Amazon S3 and CloudFront


๐ Overview
Today, I hosted a Tooplate HTML template as a static website using Amazon S3 (for storage) and CloudFront (for global content delivery). This combo is fast, scalable, and affordable for hosting portfolio sites, landing pages, or documentation.
๐ Step-by-Step: Hosting with S3 + CloudFront
1๏ธโฃ Get the Template Ready
Go to https://www.tooplate.com
Download any HTML template
Extract the ZIP file
Test it locally to make sure it works
2๏ธโฃ Create an S3 Bucket
Go to AWS Console โ S3 โ Create bucket
Bucket name must be globally unique (e.g.,
tooplate-shaharyar
)Uncheck "Block all public access" โ (weโll make it public)
Click Create
3๏ธโฃ Upload Website Files
Open your bucket โ Upload โ Select all files (HTML, CSS, JS, images)
After upload, go to Permissions โ Bucket Policy and paste:
json{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::tooplate-shaharyar/*"
}
]
}
Replace tooplate-shaharyar
with your bucket name.
4๏ธโฃ Enable Static Website Hosting
Go to Properties โ Static Website Hosting
Choose: Enable
Set
index.html
as Index documentNote the endpoint URL (e.g.,
http://tooplate-shaharyar.s3-website-us-east-1.amazonaws.com/
)
Your site is now live on S3 ๐
5๏ธโฃ Optional: Create a CloudFront Distribution
To boost speed and performance with a CDN:
Go to CloudFront โ Create Distribution
Set Origin domain to your S3 bucket static website endpoint (not the bucket name)
Leave defaults or customize:
Enable Caching
Set default root object:
index.html
Enable SSL if using custom domain
Click Create Distribution
After a few minutes, youโll get a CloudFront URL like:
https://d1ab2c3de4fg5.cloudfront.net
This serves your static site globally with low latency ๐
๐ Bonus: Use a Custom Domain (Optional)
You can use Route 53 + SSL certificate from ACM to point your domain (like yourname.com
) to CloudFront.
โ Summary
๐ฆ S3 stores your static site files
๐ CloudFront delivers them globally with speed and security
๐ก Hosting static sites with this combo is fast, scalable, and cheap
๐ก Use Cases
Developer Portfolios
Marketing Landing Pages
Resume Sites
Docs and CV pages
๐ง Today I Learned:
S3 bucket policies for public access
CloudFront caching & edge location delivery
How to connect Tooplate HTML templates with AWS
Subscribe to my newsletter
Read articles from Shaharyar Shakir directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
