… to S3 and CloudFront with Terraform

Perhaps you have followed our original guide on launching a static site using Amazon S3 and CloudFront, but are turned off by the amount of repetitive work you'll have to do if you have multiple sites.

A fully-automated cloud

Using Hashicorp Terraform, we can automate the creation and configuration of cloud resources, especially Amazon Web Services, thus providing a reproducible way of setting up the infrastructure for your sites.

Hashicorp Terraform is essentially a DSL for cloud resources. It allows you to define "resources", mapping to external entities on various cloud providers. Terraform maintains the last-known state of everything it creates, and assures on every run the live resources match what the state says they should look like.

There are enormous benefits to this, for both corporations and individuals.

Installing Terraform

Terraform is a self-contained, static binary, which makes it incredibly easy to install. Simply download it from the Terraform website and place it somewhere in your path (something like /usr/local/bin is often a good choice). Or, just keep it in the current folder and invoke it directly.

To test, ensure you can just run terraform and it should print some help. Now we can get started.