Deploy Ghost on AWS using CloudFormation - Part 04

Deploy Ghost on AWS using CloudFormation - Part 04

Deploy Ghost


3 min read

๐Ÿšจ Check out the latest source code if you are following along. I wouldn't trust the screenshots that much as they are bit outdated with latest updates to the code ๐Ÿ˜…๐Ÿ™๐Ÿป

In the part 03 of this series we got the basic infrastructure ready. Now we can continue to build our Ghost host server on that. Before anything, its best to setup AWS-CLI to use Systems Manager (SSM) so that we can connect to the Ghost host without leaving the terminal. Following the AWS documentation gets us setup in few minutes.


Also we need to have a real domain name for test secure site setup etc. I always use as my test domain and I use google domains as my domain registrar.

Now we have to setup the followings in our Ghost host.

  • Docker
  • Docker-compose
  • Traefik container
  • Ghost container
  • Route53 hosted zone
  • Route53 record set

CloudFormation made this easy by providing us some helper scripts. We use cfn-init:file to create configuration files and copy they to the appropriate places. Also we use cfn-init:commands to install and setup Docker and Docker-compose. Also we need to add Route53 hosted zone and the record set with our domain name.

The ghost-host-setup.cfn template contains all these changes. Have a quick look ๐Ÿ‘€ if needed.

We need to add an alias record as to point to I tried to create a record set for that but didn't work. So we will revisit that later.Now its time run our CloudFormation to see what it creates! [yeah, just delete the old stack to start fresh]

make create-blog-host-stack STACK_NAME=ghost-host-1

It's always handy to know where to look for any errors. On our Ghost host, we can find all the logs under /var/log

Log files under /var/log on Ghost host

cfn-init-cmd.log file is what we should look first. After the deployment our log shows happy faces.

Check all the commands for any errors

Now we can verify whether our configuration files are in place at /data/traefik. Obviously they should be as we had no errors at all.


The site is up, with one small problem ๐Ÿ˜ฌ. We have to tweak the acme.json file to get the LetsEncryption working properly. I remember got it working after few tries last time with my site, but I don't remember how I did it ๐Ÿ™ƒ. I will update this post when I work it out. But this is awesome as we got everything as code, no click-ops at all.

YEY!! we got it working!

We can start up, shut down the site very easily with docker-compose via SSM. We have to make sure to use sudo. Also we should run docker-compose in detached mode [-d flag] when we start up the stack. Have a look at the commands in the below screenshot.


Thats it for now and hanks for staying with me so far. As always the full code is on github if you want to try this out by yourself.

Cheers ๐Ÿป until next time!