Introduction to the series
Welcome to this three-part series where we’ll explore the ins and outs of hosting a static website in AWS. Throughout the series, we’ll walk through a step-by-step process of utilizing several AWS services to deploy and distribute your site efficiently. Specifically, we will cover how to:
- Use S3 to host a basic static website.
- Leverage CloudFront to securely distribute your static content.
- Utilize Lambda@Edge functions to modify requests at the edge.
- Configure Route 53 to manage DNS for your CloudFront distribution.
We’ll be using Terraform, along with the AWS provider, to configure the necessary infrastructure for hosting and distributing your static website. By the end of this series, you’ll not only understand how to deploy static sites on AWS but also have access to an open-source Terraform module I’ve created. This module simplifies the entire process, making it easier for you to replicate the infrastructure we’ll be discussing.
What are Static Websites?
Static websites consist of pre-generated HTML pages, typically created during build time, that can be served directly without requiring server-side processing. This makes static websites ideal for content-heavy platforms like blogs, portfolios, and documentation sites. Unlike dynamic websites that build pages on demand, static sites are faster and more secure since there’s no back-end logic to process every request.
There are several modern JavaScript frameworks, like Gatsby and Astro, which make building static sites even simpler. These frameworks often come with templates, allowing you to get started quickly. While this series won’t dive into building static websites themselves, a quick search online will provide plenty of resources if you’d like to explore that aspect further.
Now that we’ve established what static websites are, let’s dive into why I chose to create this series.
Why write about this? Here are three reasons.
- Static sites have enduring popularity: They’ve been around for quite some time and remain widely used within developer communities for hosting documentation, blogs, and other content-heavy sites. While there are numerous tools and templates available for building static websites, comprehensive guides on hosting them, especially on AWS, are relatively scarce.
- Going beyond the “one-stop-shop” solutions: Many cloud providers offer highly specialized services for static site hosting, like AWS Amplify and Azure Static Web Apps. These services, along with alternatives like Vite, are often covered in tutorials. However, there’s a lack of detailed resources on how to host static websites using a more flexible, service-decomposed approach—one that doesn’t lock you into a single service. This series aims to demonstrate how to utilize different AWS services to create a well-distributed and secure static website.
- Bridging the gap in Terraform resources: Despite the popularity of static websites, there aren’t many open-source Terraform modules that make deploying a static site infrastructure straightforward. One of the key deliverables of this series is a Terraform module that will allow you to quickly set up the infrastructure required to host and distribute static websites on AWS.
Source code
The Terraform configurations we’ll use throughout this series have been consolidated into an open-source module, which you can use to streamline your own infrastructure provisioning.