Set Up Your S3 Static Website with Ease Using CloudFormation

Ever wondered how to quickly set up a scalable, secure, and efficient static website on AWS?

Ever wondered how to quickly set up a scalable, secure, and efficient static website on AWS?
With this CloudFormation template, you can achieve it in just a few steps.
Building a small project? hosting documentation? managing multiple websites? Low on budget?
This solution streamlines the process and ensures consistency across deployments.

Share this post
A high-resolution digital illustration showcasing the concept of rapid and simple infrastructure setup for static websites

Why Use a CloudFormation Template for Your Websites?

Static websites are lightweight, scalable, very cost-effective, and perfect for projects like blogs, portfolios, or even small business sites.

The alternatives of using a dedicated hosting service like godaddy or hugo are expensive, have a learning curve and usually provide to many features and a similar uptime.

However, setting up your own infrastructure manually can be tedious and error-prone, especially when dealing with multiple environments or domains.

With CloudFormation, you can:

  • Automate the creation of AWS resources like S3, CloudFront, and Route 53.
  • Maintain consistent configurations for multiple websites.
  • Set up complex infrastructure in minutes.
This template empowers you to focus on content, not configuration.

aws cloud map of the affected resources, S3, Cloudfront, Route53, ACM.
AWS resources created, used or modified by the template.

How It Works and Prerequisites

The template creates and affects the following resources:

An S3 bucket, to store your website content. Prepared for static web hosting and with permissions set to allow access only of the cloudfront distribution.

A CloudFront distribution to serve content globally with low latency. Ready with the S3 bucket as origin, connected SSL certificate and a default behaviour that uses a cloudfront function to hide www and the distribution url.

Route 53 A record to connect the distribution to your hosted zone and certificate.

Before running the template:

  1. Domain Setup:
    Ensure your domain is set up as a Route53 Hosted Zone or imported into Route53.
  2. SSL/TLS Certificate:
    Use AWS Certificate Manager (ACM) to generate a free SSL/TLS certificate or import your own. This ensures your website is secure and uses HTTPS.
  3. Adjust the Template:
    Add your domain name (hosted zone name), hosted zone id, certificate arn, the bucket name you want to set and other configurable parameters from the top of the template,
    and remove the cloudfront function from the Default behavior section (if it's not needed)
  4. Run the Template:
    I am not going to explain Cloudformation, and how to actually deploy the template (console/cli/other), you can find many guides, including official AWS docs, or use an AI to walk you through the steps.

A Closer Look at the Template

The full template is available on GitHub , with detailed instructions in the README.

Get Started Today!

With just a domain, a certificate, and this CloudFormation template, you can have a fully functional static website running in minutes.
It’s fast, reliable, and the perfect solution for small-scale projects.
Try it out now and experience the power of Infrastructure as Code!
If you have questions or feedback, feel free to reach out in the comments or use the Contact Us section. Happy building!

Share this post
AWS
Cloudformation
S3
Cloudfront

Contact. Collaborate.
Subscribe. Explore.

abstract light blue and grey wave background