I like to joke about “Rabbit Holes” a lot in my professional work and side-project life. Whether it is debugging a complex issue in a huge codebase I am unfamiliar with, or trying to find the best way to host and maintain a personal blog. You will find a ton of these rabbit holes in this post and my future blog posts. I like to name drop and link to lots of software, blogs, tools, and concepts so prepare to explore deep rabbit holes.
In my journey to understand Jekyll I visited the Jekyll IRC channel on Freenode and posed a few questions about the latest release. There I met one Nick Janetakis, a very knowledgeable Ruby developer who said something that hit home and made me laugh aloud.
Before you know it, 95% of your time is spent on learning something you won't use instead of getting things done.
I have spent plenty of time doing this. So, when I finally got my little blog configured and a process I was happy with, I felt awesome about it. However, I think learning something new is exciting and beneficial. Even if you don’t end up using the shiny new thing. This is my journey to find a good working process for maintaining the source code of my blog, writing my posts, and hosting them. I won’t get too technical here but feel free to comment if you have any questions.
- Hosted on AWS S3.
- CloudFront in front of S3.
- Routing and aliases handled by Route53.
- Created using a static site generator called Jekyll.
- Deployed using a tool called s3_websites (change detection and only uploading generated files).
- Coded in a Docker container via a cloud IDE called c9.io using the Ruby template.
- Generator and site files committed to a GIT repository hosted on AWS CodeCommit.
Hosted on S3.
I have been getting into the weeds of Amazon AWS lately. It’s astounding on how many services they offer to make a developer’s life incredibly easy. Anywhere from hosting content and virtual machines to delegating off the billing responsibilities to your customers for you. They provide a fantastic service called S3 which excels in hosting static content for incredibly cheap prices. So as soon as I saw people hosting their static blogs on S3 it made too much sense not to do that myself. If you’re sick of working with shared hosting companies for solutions like this, AWS is a breath of fresh air in general.
CloudFront distributes the cached content of my blog globally making access it lighting fast for end-users.
Route53 handles my domain name. It allows me to easily point it at services like S3 or CloudFront using what they call “aliases” which are free!
Jekyll, a static site generator.
Now static sites are easy to create.
echo “Hello World” > index.html and you’re done. But there are some challenges posed when you want to add new pages, archives, pagination, you get the point. Because of this, there are a ton tools called static site generators that come in all sorts of languages and flavors. One of the most popular ones by far is jekyll which is written in Ruby. Jekyll makes it easy to add a GitHub style markdown file (like a README.md) to a folder, and create a whole static site that includes your new page.
Deployed using s3_website.
S3_website is a tool designed to easily authenticate with AWS, upload your generated site files, and save you money while doing it. It also has some very advanced features like AWS CloudFront integration and it will configure your buckets as sites and handle ACL/permissions for you too.
Coded in a Docker container via a cloud IDE called c9.io using the Ruby template.
I pay for a tool called Cloud9 IDE. They just got acquired by Amazon in July 2016. C9 can create a Docker container for you, and gives you a web editor to edit files in it and run commands against it using a terminal. What I like best is no matter where I am I can login to c9 and start coding right where I left off. I also like how I can create as many “workspaces” as I want and I don’t have to worry about variations in my underlying OS. Each project is completely isolated in its own Linux container.
Generator and site files committed to a GIT repository hosted on AWS CodeCommit.
The last step of the process is to commit all the files in my project. Including but not limited to my generator and generated files. AWS has a service called CodeCommit which integrates with AWS Identity and Access Management. This is where things will get very technical. Essentially what you do here is you create a repo, a new AWS user and give it write access to the repo and the bucket. And then you generate a keypair for the user and you put the private key on your c9 container so you can easily commit and use s3_website to push up your files. And since the creds are limited to just those areas you can easily revoke them in case of a breach.
IMPORTANT: If you use s3_website on a cloud9 public workspace make sure you store your AWS credentials in an environment variable.
Here is what creating a new blog post looks like for me:
- Create and edit a new posts file:
$jekyll buildGenerate site.
$git add _pages/*Add new files to tracking.
$git commit -m “Added new post”Commit changes.
$git pushPush changes.
$s3_website pushDeploy site.
Done. New post is instantly live on my site. Everything is checked into source control.