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 document

  • Note 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

0
Subscribe to my newsletter

Read articles from Shaharyar Shakir directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Shaharyar Shakir
Shaharyar Shakir