For the complete documentation index, see llms.txt. This page is also available as Markdown.

Add a Terraform Cloud connector

Connect Harness to Terraform Cloud.

Use a Harness Terraform Cloud connector to connect Harness to your Terraform Cloud organization. Use the Terraform Cloud connector to run Terraform Cloud workspaces and runs from Harness pipelines.


What you will learn from this topic


Before you begin

  • Terraform Cloud URL: The URL of your Terraform Cloud or Terraform Enterprise instance, for example https://app.terraform.io.

  • Terraform Cloud API token: A Terraform Cloud API token, stored as a Harness secret. Go to API Tokens in the Terraform Cloud documentation to generate a user, team, or organization token, then store the token value as a Harness secret.

  • Harness Delegate: A running Harness Delegate that can reach your Terraform Cloud instance. Go to Delegate installation overview to install one. Connect through a Harness Delegate rather than the Harness Platform, because you need a delegate later to run Terraform Cloud steps in your pipelines.

Minimum permissions

The Terraform Cloud API token must allow the following operations:

  • List organizations: Required for the connector's connection test. If the token cannot list organizations, the connection test fails.

  • Create, apply, and discard runs, and lock, unlock, and manage state versions for the target workspace: Required if you use the token with the Terraform Cloud Run or Terraform Cloud Rollback pipeline steps.


Create a Terraform Cloud connector

Perform the following steps to create the Terraform Cloud connector using the Harness Manager.

  1. Open a Harness project, and select Connectors under Project Setup. You can also create connectors at the account or organization levels.

  2. Select New Connector, and then select Terraform Cloud under Cloud Providers.

Overview

Enter a Name for the connector. Description and Tags are optional. Harness automatically creates an Id (entity identifier) for the connector based on the Name. Select Continue to proceed to Credentials.

Overview step of the Terraform Cloud connector wizard

Credentials

Select Continue after entering the following details:

  • Terraform Cloud URL: Enter your Terraform Cloud or Terraform Enterprise URL, for example https://app.terraform.io.

  • API Token: Select Create or Select a Secret to add your Terraform Cloud API token. Go to Before you begin for how to generate the token.

Credentials step of the Terraform Cloud connector wizard

Select Connectivity Mode

Under Connect to the provider, select how you want Harness to connect to Terraform Cloud, and then select Save and Continue:

  • Connect through Harness Platform: Harness communicates with Terraform Cloud securely through the Harness Platform. Credentials are encrypted and stored in the Secret Manager configured in Harness.

  • Connect through a Harness Delegate: Harness communicates with Terraform Cloud through a Harness Delegate installed in your environment. Select this option if Terraform Cloud is behind a corporate firewall.

Select Connectivity Mode step of the Terraform Cloud connector wizard

A Harness Delegate is used for deployment operations even if you select Connect through Harness Platform.

Delegates Setup

This step appears only if you selected Connect through a Harness Delegate. Select one of the following options, and then select Save and Continue:

  • Use any available Delegate.

  • Only use Delegates with all of the following tags: Enter the tag of the delegate you installed.

Delegates Setup step of the Terraform Cloud connector wizard

Connection Test

Harness validates the Terraform Cloud connector authentication and permissions. Once verification succeeds, select Finish.

Connection Test step of the Terraform Cloud connector wizard

The connector now appears in the Connectors list.


YAML example

The following YAML defines a Terraform Cloud connector that authenticates using an API token and connects through a Harness Delegate.

Terraform Cloud connector YAML

Next steps

Last updated

Was this helpful?