Continuous Blog Publishing with the AWS Amplify Console
On my growing TODO list there’s a section I call The Great Big Beautiful Tomorrow. It’s the subset of tasks that would undoubtedly save time or be valuable to do, but continually get pushed down the stack due to priority starvation. Sometimes I check in on them briefly, and then guiltily scroll away before I make eye contact. They are imprisoned in my Katamari-like list of good intentions. Toward the bottom, there’s a agglomeration of blog-related items including one that reads “write blog posts.” Yeah. Shut up, TODO. I’ll get to it. Somewhere below that another reads: “setup a publishing pipeline for the blog.”
A deployment pipeline is an automated manifestion of the process for
getting software (or, in my case, rubbishy content) from a version control
system into the hands of customers. I’m a big fan of AWS CodePipeline,
AWS CodeBuild, and friends: AWS services which help developers to quickly
create Continuous Delivery pipelines without managing servers or
Jenkins or whatever. I had the rough outline of what I would do mapped out
in my head. I’d create CodeBuild project with a build.yaml
that executes
hugo
, create a pipeline in CodePipeline to monitor my GitHub repository, build
the site, and then copy it to Amazon S3. It would take an hour to setup
perhaps, and save me from clumsily trying to remember the AWS CLI incantation to
synchronize my repo with the S3 bucket. It would be auto-magic! The future is
bright and wonderful.
But, ehhh. I guess I’ll need to put it in some kind of AWS CloudFormation template. I’ll probably need to look up the syntax. That sounds boring. The Internet has so many fun things to read and do and watch. If the Internet wasn’t fun I probably would have gotten this done, but it is, so I didn’t. Instead, after my infrequent blogging, I did the CLI futzing and often got the files copied. It is a task that supports inertia by being annoying but not painful or time intensive enough to fix properly.
Last week I joined the AWS Amplify team working on the Amplify for
Android framework. Part of Amplify’s suite of products is the AWS Amplify
Console which provides hosting for fullstack serverless applications. It
connects to repos on GitHub, Bitbucket, or GitLab, runs a build, and deploys the
result to Amazon S3 behind Amazon CloudFront for content delivery.
Plugging in my blog repo in the console, I was blown away to see it create a
full publishing pipeline for my blog. Not only did the console detect that the
blog used Hugo as a static site generator, but when I hit Save and Deploy, it
published the content of the site in less than a couple of minutes. A few more
mouse clicks, and I had a free SSL certificate from AWS Certificate
Manager, and rewrite rules in place. Since I host my domain in Amazon
Route 53, the Amplify Console was even able to automatically create the
CNAME and ALIAS records to wire the site up to production. Now everytime I push
to master, my blog would be immediately deployed without any additional steps.
Without intending to, I had unwittingly crossed an item off my TODO list. That’s lifehacking, friends.
The service is built around the Git workflow many developers use. A simple git push
results in a production deployment without any fuss. In our
slightly-kind-of-irritating status quo of Kubernetes clusters and masturbatory
complexity, it’s a glass of ice water in hell. I don’t have to think
about servers, clusters, scp
'ing something somewhere, command line options to
arcane CLIs, or anything beyond git push
. More of this please.
So what’s the catch? AWS Amplify Console is priced on a pay-as-you-go-basis along the dimensions of build minutes, storage, and data served. The free tier provides 1,000 build minutes, 5GB of storage, and 15GB of data served. Not only did I luck into a more efficient deployment process, I serendiptiously saved some cash as now this blog is hosted absolutely free. No catch.
But wait! There’s more! AWS Amplify Console meets developers where they are by improving the review component of their Git workflow. Through a feature called Web Previews, pull requests are built and deployed to their own URL for QA of the actual rendered content. Through an integration with GitHub, pull requests have an AWS Amplify Console Web Preview check that builds and deploys content when the PR is opened or updated.
Within Details, the link to the fully rendered site can be found:
This allows reviewers to see the final rendered product of the change and provide more meaningful review. Preview sites can even be optionally password protected to prevent prying eyes or issues with duplicate content.
AWS Amplify Console supports other static-site generators besides Hugo such
as Jekyll, VuePress, Gatsby, Eleventy, and any kind of static sites using
frontend frameworks like React, Angular, etc. I can’t say enough good things
about it, but since I’m on the payroll please don’t take my word for it.
Getting Started is easy and free. Just connect your repo and you’ll
be continuously publishing.