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
- Install the OpenTofu
tofu
CLI.
Manging Terraform Deployments
-
Navigate to a Terraform directory (eg.
_infra/terraform/glhf
) -
Initialize Terraform providers:
tofu init
noteTerraform 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, likeaz
oraws
, depending on the project you are managing. -
Calculate diff between code and production:
tofu plan
-
Deploy Terraform diffs:
tofu apply
warningThis can break production state or increase costs. Make sure the diffs are what you intend to deploy.