A Beyondsoft Company

Stacy: S3-served dynamic websites

23 Sep, 2016

Serving a website from Amazon S3 is great: it’s fast, it’s inexpensive, and it doesn’t require maintaining a web server. But this simplicity can be limiting, coming at a price: you can only serve absolutely static files; there is no server-side logic whatsoever.

On the other hand, we are now seeing the rise of so called “API-first content management systems.” These systems, in true cloud spirit, are usually provided as a hosted service, give you  a standardized user interface for structuring and managing your content, but do not deal with any aspects of your content presentation. They don’t deal with themes, templates, pages, etc. Instead, you have a fast and simple RESTful API that gives you access to your content and you are free to render it with whatever presentation you want outside of the CMS.

I liked this idea and decided to create something that can sit in between such API-first CMSes and Amazon Cloud, can detect changes in the content, can automatically run some logic to combine the content with templates to generate the pages, and can finally publish them in S3. This new tool is called Stacy, it’s open source, and it lives at:

The CMS that Stacy works with is Contentful, which offers free accounts that allow for a decent amount of functionality, including webhooks. When a piece of content – a page, a module, or an asset like an image file – is published, the webhook sends an HTTP POST to an endpoint defined in Amazon API Gateway. The endpoint creates an event record and writes it to an Amazon Kinesis stream. On the other side of the stream, an AWS Lambda function is triggered. The function calls the Stacy module, which loads the necessary content from Contentful, compiles affected pages using Handlebars templates, and finally uploads the HTML to the Amazon S3 bucket, from which the site is served. Stacy also copies asset files to S3 and takes care of unpublish events, removing the unused content.

One thing that remains for me to do is to write a detailed Tutorial, as setting up a complete AWS infrastructure and a website project for Stacy from scratch involves several steps that do need to be reinvented over and over by whomever wants to try it out.

[EDITOR’S NOTE: Boyle Software will host a Tech Talk soon where Lev Gimelfarb will discuss Stacy in more depth. Stay tuned!]