Skip to main content

Terraform Setup

Terraform is a (formerly open-source) infrastructure-as-code tool for managing resources in code.

We use it to declaratively manage our production resources with version controlled code instead of manually hand-configuring them in UIs, which can lead to errors, broken state, and high maintenance costs.

We use OpenTofu, an open-source fork of Terraform managed by the Linux Foundation.

First Time Setup

  1. Install the OpenTofu tofu CLI.

Manging Terraform Deployments

  1. Navigate to a Terraform directory (eg. _infra/terraform/glhf)

  2. Initialize Terraform providers: tofu init

    note

    Terraform may need local CLI tools or variables to manage production resource. You may need to create a terraform.tfvars file or set up auth for local CLI tools, like az or aws, depending on the project you are managing.

  3. Calculate diff between code and production: tofu plan

  4. Deploy Terraform diffs: tofu apply

    warning

    This can break production state or increase costs. Make sure the diffs are what you intend to deploy.