Computing

The Move to AWS

September 12, 2019 - 11:18 am

Amazon-CloudFront@4xAmazon-Simple-Storage-Service-S3@4xAmazon-Route-53@4x

I'm happy to say this website is now fully static and hosted by AWS! Since its creation in 2009 (10 years ago!), micahjayne.com has been running off a LAMP stack on an old desktop at my parents' house. Learning how to setup a web server was a lot of fun and a great experience. I also didn't have to pay for any hosting, so I could spend all of the paychecks from my minimum wage job on musical instruments instead.

It's had some issues, though. The occasional-to-frequent power outage at my parents' house meant I had to call them to restart the server whenever it went down. I set up email alerts through a service called Statcounter that would email me whenever the server went down. Sometimes it'd come back up in an hour or so, other times I'd have to call tech support (my parents) to reboot the server. It was rare I'd ever have a month with 100% uptime. A couple years ago, I bought them a UPS and plugged the server into it (okay, I bought me a UPS. But they're using it for their computer too!). This helped with the outages a lot, but the uptime was still never 100%, due to occasional internet outages.

Ever since I learned about static website hosting with S3, I really wanted to move my website over to it. There was one major sticking point, however — this blog. I know, I haven't posted on here in 3 years, and rarely posted even before then. Still, there's some stuff here that's somewhat sentimental that I'd like to keep around, for my own records, if nothing else. But the blog was stopping me from just dropping all the files in an S3 bucket and calling it a day, so I put it off for a while.

Then I learned about Jekyll, a way to statically host a blog. This is exactly what I wanted, so over a very long Memorial Day weekend, I finally took the plunge.

It makes a lot of sense. Pre-computing all the pages beforehand and statically hosting them. This makes loading considerably faster (and a lot more secure, too). Do all of the computing once, beforehand, not every time a user visits the site. This makes sense for a lot of blogs, especially mine considering the frequency of updates.

Getting Jekyll set up initially was super simple, but it took a lot of tweaking to get things exactly how I wanted them. I wanted to maintain the same look of the old blog, including the sidebar with categories and archives. For the categories, initially I was able to achieve this using a plugin called jekyll-archives. However, when I started working on implementing pagination, things got more complicated. I ended up using the autopages feature of jekyll-paginate-v2 to generate the category pages, but still using jekyll-archives to generate the monthly pages (those are always so small that they never need pagination). It took a lot of experimentation and trial-and-error, but I eventually got everything to my liking.

After I finally got all the files staticized, it was time to upload everything AWS. Getting the S3 bucket and CloudFront distribution was a snap. The AWS documentation actually has a pretty good guide if you're interested in doing this yourself. It takes you through setting up the S3 bucket, setting up a CloudFront distribution to point to that bucket, as well as setting up a custom domain with Route53. Transferring the domains took some time unfortunately, just due to my previous registrar taking a long time to release them.

All said and done, everything is lightning fast now, downloading files especially. Right now, the S3 and CloudWatch costs are fully covered by the Free Tier. Once that expires after a year, the costs will be <<$1/mo. I moved domain name registration from Namecheap to Route53. I never really had any issues with Namecheap, but having everything in AWS makes things a bit easier. Setting up HTTPS certificates for CloudFront is one-click, CloudWatch-served traffic is free, also the DNS service is better (though total overkill in my case). The yearly registration cost is slightly cheaper, but I do have to pay $0.50/mo for the hosted zones. Still, overall I'm paying less than a couple bucks a month for hosting 3 websites, which is amazing. I also moved my other two websites to CloudWatch + S3 + Route53 (these were already static, so they were very easy to migrate). In the future, for some improvements, I could add comments via Disqus or search via Bing or Google, but I don't really feel the need for them at the moment.