Skip to content

hashicorp/terraform-provider-tfe

Terraform

HCP Terraform and Terraform Enterprise Provider

The official Terraform provider for HCP Terraform and Terraform Enterprise.

As Terraform Enterprise is a self-hosted distribution of HCP Terraform, this provider supports both Cloud and Enterprise use cases. In all/most documentation, the platform will always be stated as 'Terraform Enterprise' - but a feature will be explicitly noted as only supported in one or the other, if applicable (rare).

Note this provider is in beta and is subject to change (though it is generally quite stable). We will indicate any breaking changes by releasing new versions. Until the release of v1.0, any minor version changes will indicate possible breaking changes. Patch version changes will be used for both bugfixes and non-breaking changes.

Installation

Declare the provider in your configuration and terraform init will automatically fetch and install the provider for you from the Terraform Registry:

terraform {
  required_providers {
    tfe = {
      version = "~> 0.54.0"
    }
  }
}

For production use, you should constrain the acceptable provider versions via configuration (as above), to ensure that new versions with breaking changes will not be automatically installed by terraform init in the future. As this provider is still at version zero, you should constrain the acceptable provider versions on the minor version.

The above snippet using required_providers is for Terraform 0.13+; if you are using Terraform version 0.12, you can constrain by adding the version constraint to the provider block instead:

provider "tfe" {
  version = "~> 0.53.0"
  ...
}

Since v0.24.0, this provider requires Terraform >= 0.12

For more information on provider installation and constraining provider versions, see the Provider Requirements documentation.

Usage

Create a user or team API token in HCP Terraform or Terraform Enterprise, and use the token in the provider configuration block:

provider "tfe" {
  hostname = var.hostname # Optional, for use with Terraform Enterprise. Defaults to app.terraform.io.
  token    = var.token
}

# Create an organization
resource "tfe_organization" "org" {
  # ...
}

There are several other ways to configure the authentication token, depending on your use case. For other methods, see the Authentication documentation

For more information on configuring providers in general, see the Provider Configuration documentation.

Development

We have developed some guidelines to help you learn more about compiling the provider, using it locally, and contributing suggested changes in the contributing guide.