Hatch.

Hatch logo

Hatch makes it easy to manage your static websites on AWS — Hatch takes cares of creating S3 buckets and configuring your custom domains in Route53 — All from the comforts of your command line.

Installation

On macOS you can install Hatch using Homebrew:

brew tap hatch-sh/hatch
brew install hatch
hatch --version

This will install Hatch as well as Zsh and Bash completion scripts so you get nice helpful tab-completions in your shell. For the Bash completions to work you need to have the bash-completion homebrew package installed. For Zsh completions to work you need to be using oh-my-zsh.

On other platforms you can install Hatch as a pip package

pip install hatch-cli

Or you can install it from source

git clone git@github.com:hatch-sh/hatch.git
cd hatch
make install

Configuration

AWS

As Hatch helps you deploy static websites to AWS you need to have an AWS account — You can create a free account here.

The AWS services that Hatch is using are very inexpensive but they aren't free. See AWS Pricing for more information.

Hatch uses the default way to configure AWS. You can read more about that here.

Hatch

You can configure Hatch through command line arguments (see hatch -h for more information) or through a YAML configuration file. By default it looks for a file named website.yml in the current directory but you can also choose to pass a configuration file using the --config-file option.

The following configuration options are currently available:

  • path: The path to the folder you want to deploy. By default it will deploy the current directory.

  • name: The name of the S3 bucket to upload your site to.

  • domain: The custom domain name you want to use. This requires that you have transferred the domain to your AWS account using Route53.

  • region: The AWS region in which to deploy the site. If unspecified it will use the region you've specified in your ~/.aws/config file

A configuration file might looks something like this

domain: "hatch.sh"
path: "./dist"
region: "eu-central-1"

And using command line arguments that would be

hatch website deploy \
    --domain hatch.sh \
    --path dist \
    --region eu-central-1

Deploying

All of these examples can be achieved through command line arguments or through a YAML configuration file (see seciton above). we use command-line arguments here.

Auto-generated URLS

If you don't supply a name or custom domain Hatch will simply upload your site to a randomly generated bucket.

hatch website deploy

Named buckets

If you use the name option you can control the name of the bucket and thus the prefix of the S3 website URL.

hatch website deploy --name myname.com

Custom domains

By using the domain option you can use a custom domain if you've registered it in Route53.

hatch website deploy --domain myname.com

Examples

This site is deployed using Hatch on Travis. The site is generated using Gatsby.js. You can see the code here.

Relevant AWS pricing

Storing and serving static content using S3 is extremely cheap. You can see the prices for your region here.

If you're using a custom domain then see the prices for Route53 here.

Background

Amazon Web Services provides an overwhelming number of services and tools that will help you build your products. These services are highly configurable and can be shaped to your individual use-cases. This is very powerful but it comes at a cost. Building simple products using AWS like a small API, a static website, etc. usually requires the use of several different services and takes a huge effort when it comes to configuration. We wanted to change that with Hatch.

By focusing on a few simple use-cases we've been able to automate the entire creation and deployment for you so you can focus on building your product. For now we only support static websites but we have serverless APIs using API Gateway and AWS Lambda in the the works as well.

Made with ❤️ by Mads Hartmann & Kenneth Skovhus