Eat.Sleep.Learn.Repeat

My way of reminding my future-self about stuff

Hugo and AWS Quick-Start

Being this a pet project, having the minimum cost and maintenance effort posible is a must. AWS is a very good method to deploy an maintain a blog acomplishing both objectives. AWS offers S3 to store objects (files) on the cloud, and it has the built-in capability to serve those objects, as static web pages. This makes it a no-brainer to go for a fully static website, without having to run and maintain a web server, plus a PHP/Ruby/your_language_of_choice runtime pre-processor, plus a CMS.

To go CMS or CMS-less

I have run many website in the past, with a plethora of different CMS (Content Management System). From Joomla, to Drupal, to WordPress. Let me put it this way: I am susbcribed to too many Security-Announce lists for too many software/hardware products already. I don’t WANT to maintain more software up-to-date to solve the latest 0-day exploit. I don’t need no CMS. I can use vi (which incidentally is almost as old as I am) or Visual Studio Code (good job Microsoft) to edit my site directly. So no CMS it is.

Static Website Frameworks

Many frameworks/tools exist nowadays, that help you render a fully statically hosted website, but still keep some nice functionality at build time with little effort, like tags, categories, etc… I researched a few and settled with Hugo. It seems to strike a balance between broad adoption and low enough learning curve for the spare time I have available right now. It also forced me to take a deeper look at GO, which is also a good thing. Obviously, I have not discovered/invented anything, this is precisely one of the intended uses of S3: hosting static web content. Consequently, AWS has published a nice QuickStart here. Their example also uses CloudFront to speed-up page serving by using the extensive AWS CDN, and Route53 to host the domain. Serving from CloudFront also seems to be cheaper than serving directly from S3 (I still have to do the cost analisys).

S3/CloudFront and APEX domain

There is a caveat for serving the apex of your domain (root domain) directly from S3, because S3 requires the use of a CNAME. You cannot use a static IP address with S3. If you read RFC 1912, section 2.4 you find:

2.4 CNAME records
 A CNAME record is not allowed to coexist with any other data. 

All in all, this means that the required DNS MX record, to be able to receive mail addressed to your domain, cannot coexist with a CNAME record at the root level. So it is either serving a page from your apex domain, or receiving mail, you choose. There are two ways to solve this:

  • Use Route53 and take adavantage of its Alias record, which incidentally is not a CNAME.
  • Host your apex domain on another webserver and redirect the root page with a 303 Redirect.

But the second option defeats the purpose of not running a webserver in the first place, so Route53 it is.

That’s it for now, further posts about how this blog came to be will be posted in the near future.


Share