Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Terraform

Overview

Terraform is a an infrastructure as code solution that allows you to provision, change, and version and resource in any cloud environment.

Some common use cases for terraform are

  • Writing infrastructure as code to automate the provisioning of your services.
  • Usage for a multi cloud deployment
  • Managing a kubernetes setup
  • Easily manage network infrastructure

Terraform allows small teams to work fast and scale quickly. Having all of your infrastructure managed by a set of reproducible code, you can quickly manage your deployments without the need for dedicated devops or infrastructure engineers.

Terraform CLI

The terraform cli is pretty straightforward, and documentation can be found here

Basic CLI Features

One of the most useful functions of the cli is that if you are connected to a terraform cloud backend you can switch workspaces. This allows you to use the same provisioning code for many (even slightly different) projects. Without workspaces you generally would be overwriting current resources.

A workspace can be configured like so

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 4.0"
    }
  }

  backend "remote" {
    organization = "adajcentresearch"
    hostname = "app.terraform.io"

    workspaces {
      prefix = "adjacent-"
    }
  }
}

Terraform Cloud

Cloud manages all remote builds along with maintaining a compete overview of al infrastructure deployed under the organization.

TerraformHashiCorp Cloud Platform

Examples

Examples of a terraform deployment with NixOS can be found below