Skip to content

Terraform Setup

Daniel Chiquito edited this page Dec 11, 2020 · 1 revision

Copied from the Kitware AFI Notion for public perusal.

Terraform Setup

I pulled from https://github.com/girder/dkc-next/tree/master/terraform for inspiration in writing a basic [main.tf](http://main.tf) , heroku.tf, and versions.tf. These can be seen here.

Filling in the blanks made it fairly obvious what was required:

  • A Terraform backend. I had to set up an organization and a project on app.terraform.io. The project's Version Control was connected to the GitHub repository and set to trigger automatically. I set the Terraform Working Directory to terraform, as that is where I stored the .tf files.
  • A Route 53 domain. An AWS organization and credentials were already set up, all I had to do was purchase a domain name (shapeworks-cloud.org).

I plugged that info into the Terraform files, then ran terraform init and Terraform was set up to administer the environment.

For authentication, I had to register an AWS access/secret key and a Heroku email/API key as Terraform variables. I used my personal accounts for doing that.

I pushed the terraform directory to master, which triggered Terraform cloud to run and create most of the resources, including the Heroku app.

The terraform-heroku-django Terraform plugin describes some gotchas on initial setup. As described, the first Terraform plan failed to actually deploy the Heroku dynos because the freshly created Heroku app did not have any code to deploy, so I had to go into the Heroku app and manually connect the repository using Deploy > Deployment Method > GitHub and enable Automatic Deploys. Manually queuing a Terraform plan on the web dashboard completed successfully.

At this point, both the Terraform cloud project and the Heroku app are manually pointed at the GitHub repository. If we ever want to move the code base (it's currently stored under the girder proejct), we will need to remap it in both the Terraform project and the Heroku app.

Since user registration requires sending a verification email, Amazon SES needs to be set up, which is also described in terraform-heroku-django. This took ~24 hours for Amazon to process.

Clone this wiki locally