Back to blog

Terraform Static Site Setup Updates

I started building this set of Terraform scripts around a year ago to learn Terraform in a way that was concrete for me. I love making little static websites with AWS S3 and Cloudfront, so having a way to make it even easier seemed like a nice project. The goal was to automate all of the basic AWS S3/Cloudfront configuration I had been doing by hand. Admittedly, it was pretty quick even manually, but having Terraform do it would be even faster.

So when it came time to build this website, I resurrected the project and made some minor tweaks to it. It was pretty robust already so there was not much needing to be done at that point.

But everything is a work in progress and there’s always more to be done somewhere.

I came back to this little project recently and realized a few gaps. The first was that…well, after I set it up on a new computer, it was not recognizing the existing resources I wanted to manage. This was as I did not have the Terraform state on my new computer. So, in the Terraform plan, it was creating brand new resources rather than updating the existing ones.

The solution was to use Terraform Import command. I imported the existing infrastructure and it was good to go. The README now has documentation regarding those commands.

After I was able to update the existing resources rather than creating new ones, I added the custom_error_response for the 404 page (I had manually applied this…) and updated the TLS minimum protocol version to the Cloudfront setup.

With those polishes in place, I finally put an MIT License on it so people can freely poke at what I had put together over all this time. It’s nothing special or that exciting, but it gets the job done for what it aspires to.

Read more on similar topics