Gatsby + Sanity + AWS free micro instance

There is a great article by Katie from Katie Kodes blog about setting up a live dev site with heroku, Gatsby & Sanity. I wanted to share my solution which is with an AWS EC2 t2.micro free tier instance. I have found Gatsby Cloud to be limiting in the amount of real time preview edits and always hit the limit with my very simple sites. So let's get started...

This tutorial assumes you already have a gatsby site and a sanity cms running and connected to eachother. If you need a guide on how to get that setup you can follow our ​ ​Definitive Guide to Setting up with GatsbyJS ​ you only n​eed to follow up to the point of locally running Sanity and Gatsby. Once you have done so we can start by setting up an EC2 Instance on AWS. You can use an Ubuntu t2.micro instance that is under the free tier, I haven't had to pay for any of my instances so far. ​

Lets start by opening up aws console, navigating to EC2 clicking launch instance and you should see a page like below, click the select button for Ubuntu 18 and continue below

Now you will see the page below, free tier should be selected already if not choose it, and then click the next configure instance details button in the bottom right corner, seen in the screenshot below

You can click through a few of the next options. For the configure instance details page, just click next add storage, on the storage page leave the default 8gb and click next add Tags. On the tags page add one tag Name: name-of-your-website seen below. Then click review and launch.

After click review and launch, review the setup and then click launch. After clicking launch, this next part is very important it is how you will connect to you instance securely. Choose Create a new key pair and name it something descriptive. You can see mine below, then click donwload, once it's donwloaded onto your machine click launch instance