hugo serverless
Cheap solution for a self-managed blog? Why not hugo static pages -> s3 and have AWS route53/cloudfront/aws certificate manager. I can’t imagine this being more than the price of coffee per month.
Hugo
Hugo generates static pages and works for simple blogging. Using some freely available themes, one can generate some reasonable looking posts. Since it’s written in Go, it’s also snappy to run locally to preview and generate content.
S3
Host on S3 by creating a static website S3 bucket and enabling public access. While I could setup some automation from Git to S3 publishing, I’ll save that for another day, since publishing from hugo deploy is pretty easy as well.
Redirect rules
Setting up the S3 bucket to be a static website origin with the following works without a CloudFront.
{
"IndexDocument": {
"Suffix": "index.html"
},
"ErrorDocument": {
"Key": "404.html"
},
"RoutingRules": [
{
"Redirect": {
"ReplaceKeyWith": "index.html"
},
"Condition": {
"KeyPrefixEquals": "/"
}
}
]
}
Route53/CloudFront
Setup DNS in route53, and generate a certificate using AWS Certificate Manager since we always want TLS.
Deploy a CloudFront config using the S3 origin and the TLS certificate. Each publish in CloudFront can take like 15mins, so it’s coffee break time.
What’s disappointing with CloudFront? It could not handle some simple URI rewrite rules for taking a ‘/’ and converting it to ‘/index.html’. The AWS solution for this was to write a lambda function, and then enable some trusted permissions. This seems better suited for config
rather than custom functions, but for a low volume blog, I guess this will do for now.
More details from this nice writeup on the lambda. https://dev.to/geekgalgroks/using-lambda-to-rewrite-urls-for-hugo-2joi