Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Cloudformation templates for web hosting infrastructure using S3, CloudFront, ACM, and CodeCommit. I set these templates up to roll out infrastructure to support really cheap static sites on AWS.


If you want the static-site-stack to create Route53 records, you need to have the domain configured. Pass the ZoneId during deployment and it'll create them. I'm using external DNS for my personal website, so I made that part conditional. Another thing you'll need is the Build Job. I plan on making this conditional in the future, but I ran out of time.

Table of Contents


This stack holds the ACM cert for CloudFront.


Provides free SSL certificates.


The core of the hosting stacks.


S3 is the hosting platform for the static pages. It's simultaneously scalable and inexpensive. There's also a second bucket for S3 and CloudFront logs.


CloudFront provides SSL termination. If you don't want https, this part is unnecessary for the hosting. The benefits are debatable. Important point in this config is that I'm using S3's WebsiteURL instead of the DomainName. This makes the directory reference function properly.


Conditionally creates alias records for the CloudFront endpoint.


This stack contains the CodeCommit repo for the code and trigger for the build job. I think in the future, I'll make the trigger conditional so that it doesn't require the build job stack to exist before you can deploy the repo. A quick update-stack command after the build job exists should be enough to add the trigger.


I went with CodeCommit because it's a free, private repo for small projects. GitHub is a much better choice for large, mature projects, but I wanted to understand CodeCommit's limitations, which are many. The trigger has a custom data property that tells the deploy job which bucket to push to.

External Resources

These resources exist outside the infrastructure stacks.


I set up a lambda, written in python, that builds the static site and pushes it to S3. My static sites are developed with Hugo, so the Hugo binary is bundled into the lambda package. This lambda is deployed as a separate stack because it's project agnostic. I have many static sites to host in this account, so I made the lambda universal. Not all static websites will use this same build process, so I'm leaving it flexible.


To deploy these resources, I've supplied a Makefile to deploy the stacks. I didn't put in the effort to make these create/update automatically, so if you need to update a stack, you'll need to modify the cli command to update-stack.


The deploy jobs take a few parameters to fill in the stacks.

  • RootDomainName - The domain name of the project.
  • ProjectShortName - A short name that helps label all the stacks and resources.
  • ZoneId - Optional, Include if you want the stacks to deploy DNS aliases for CloudFront.


Cloudformation templates for web hosting infrastructure using S3, CloudFront, ACM, and CodeCommit.




No releases published


No packages published