• Docs
  • Common Use Cases
  • Remote State
  • Terraform Cloud

Terraform Cloud

It's possible to use Terraform Cloud as a remote backend to store and manage state files.

Terraform Cloud Token

Terrateam needs a Terraform Cloud user API token in order to authenticate against the Terraform Cloud remote backend.

  1. Navigate to the Tokens section of the Terraform Cloud Console

Tokens

  1. Select Create an API token

Create an API token

  1. Choose a Description and select Create API token

API token description

  1. Save your token in a safe place as it will not be displayed again

Create API token

Workspace Configuration

Terrateam can work with existing Terraform Cloud workspaces or a newly created workspace.

New Workspace Configuration

  1. Select Workspaces in the Terraform Cloud Console

Workspaces

  1. Select New workspace in the top right corner

New workspace

  1. Select CLI-driven workflow

Workspace type

  1. Choose a workspace name and description and select Create workspace

Workspace configure settings

  1. Navigate to Settings

Workspace settings

  1. Set Execution Mode to Local and select Save settings

Workspace settings execution mode

Existing Workspace Configuration

The execution mode of your Terraform Cloud Workspace must be set to Local.

  1. Select your existing workspace in the Terraform Cloud Console

Workspaces list

  1. Navigate to Settings

Workspace settings

  1. Set Execution Mode to Local and select Save settings

Workspace settings execution mode

Granting Terrateam Access

  1. Navigate to the main page of your Terraform repository on GitHub and select Settings

GitHub repo settings

  1. In the left sidebar, select SecretsActions

GitHub repo settings secrets actions

  1. Select New repository secret

GitHub repo settings secrets actions new repository secret

  1. Populate the Name and Secret fields and select Add secret
  • Name: TF_API_TOKEN
  • Value: <Terraform-Cloud-API-Token>

GitHub repo settings secrets actions new repository secret populate

The Terrateam GitHub Action will automatically detect your newly created GitHub Secret TF_API_TOKEN and create the required configuration in ~/.terraformrc.

Backend Provider Example

Basic configuration to start using Terraform Cloud as a remote backend:

terraform {
  backend "remote" {
    hostname = "app.terraform.io"
    organization = "<your-terraform-cloud-organization>"
 
    workspaces {
      name = "production"
    }
  }
}