When I decided to start my personal blog once again I knew that I want to build it based on some static site generator. There is plenty of options depending on which language you would like to use. My weapon of choice if Ruby so Jekyll natural choice.
If you prefer to watch video (and you know Polish) over reading this you can watch movie below. It was recorded during my keynote during Trójmiasto Ruby User Group.
Since I decided not to use Github pages then keeping blog source code in Github was no-no. Closest git repository to S3 is AWS CodeCommit. It is like Github, but from Amazon Web Services … Looks very like Github, 10 years ago. But it works, which is enough for me.
I like the idea of serverless
computing. I have
some experience with AWS Lambda
framework (terrible name for framework!). Do
you know what is the best with this S3 - Lambda combo? You can setup
your CodeCommit repository to
trigger Lambda function on every
change in your
master branch. Isn’t it nice? Every
git push will
trigger deploy of my blog. Continous
- Get the list of files changed
- For every changes file get recent content
- Save file on S3 bucket
- Perform some extra (will describe it later)
As I said before: nothing fancy. Of course in such approach in git repository I keep both markdown and HTML files.
From this moment content inside your S3 bucket is available under
What is worth to mention at this point is when you enabled S3 website
you can (and you should) set some nice properties for each object in
this bucket. You need to set property named
index.html you need to set
otherwise browser will render your HTML page as
text/plain. You can
also set any other HTTP header properties this way like for example
Cache-control. I set this for each file being uploaded to S3 bucket
in my AWS Lambda function.
But of course it is not domain under which your would like to host
your blog. No worry! You can point your domain directly to AWS
S3. GOTCHA alert! You need to name your
exactly the same as your domain. For example my blog is hosted under
mergujmyniktniewola.it and my S3
bucket name is
In near future I will publish source code of my Lambda function for deploying https://mergujmyniktniewola.it. So far all AWS infrastructure, except those for Serverless, was done by hand in AWS management console. I will try to automate this using some provisioning tool.
Now it is time to sum up. This way of hosting static site is very
cheap in my case. Deploy is blazing fast. In less than second after I
git push new version of HTML is ready to be served to
readers. I encourage everyone to try use AWS
Lambda and hack some stuff.