How This Site Was Built
As I’ve started working with AWS a lot more recently I wanted to host my own site on the platform. Knowing that this will be a simple site that will most likely only be viewed by me, I didn’t want to spend very much on the implementation. S3 static site hosting was a perfect fit.
There are many articles on how to setup S3 to host a static site so I won’t get into the details here. However, here are some things that I learned while going through this process:
- Your bucket name must match your URL if you intend to use your own domain name.
- To redirect you’ll need another bucket with the redirecting address. In my case I wanted to redirect www to the root address.
- If you want to use SSL you’ll need to attach your certificate to a CloudFront distribution.
- CloudFront caches content so deploying changes may not show for some time without changing the file names or forcing invalidation. Invalidation can incur a charge so it’s not the ideal method.
- Public certificates from AWS Certificate Manager are FREE!
I had been using LetsEncrypt in the past for SSL certificates, but seeing that the price tag for public certificates with AWS Certificate Manager was the same…free…I decided to switch.
Having DevOps in my title and all, I also wanted to automate the deployment of changes to the site. To do this I’m using CodeBuild to create an artifact of the static website files explicitly to separate infrastructure and Hugo code and only push what’s necessary to the S3 hosting bucket. CodePipeline is used to run this “build” when there’s a new commit in the CodeCommit repository. After the “build” stage CodePipeline then pulls the created artifact and copies the static web files to the root S3 hosting bucket. It’s not the fanciest deployment model as I’m directly overwriting the live site and not doing any cool blue or green or even red or black goodness. But for a small, inactive, static site it works for my needs.
I’ve been happy with this method and the price has been excellent.
My monthly bill has been right around $1 per month with Route53 being the largest portion. Of course this is with no load and a small footprint of assets in the S3 bucket, but still much cheaper than running something with compute.
How about a picture?
Comments powered by Talkyard.