Skip to content

hashicorp/go-tfe

Folders and files

NameName
Last commit message
Last commit date
Jan 23, 2025
Nov 7, 2022
Nov 18, 2024
Nov 19, 2024
Jan 7, 2025
Feb 19, 2025
Feb 21, 2023
Sep 13, 2024
Jan 27, 2023
Mar 11, 2024
Apr 26, 2023
Feb 19, 2025
Oct 12, 2022
Mar 16, 2023
Jan 13, 2025
Aug 13, 2024
Nov 13, 2024
Aug 13, 2024
Nov 13, 2024
Aug 13, 2024
Nov 13, 2024
Aug 13, 2024
Jan 2, 2024
Mar 21, 2023
Jan 27, 2023
Jan 27, 2023
Jan 27, 2023
Jan 27, 2023
Aug 2, 2024
Aug 2, 2024
Mar 21, 2023
Mar 22, 2023
Jul 12, 2023
Nov 14, 2024
Jan 27, 2023
Nov 13, 2024
Jan 27, 2023
Jan 27, 2023
Feb 3, 2025
Feb 3, 2025
Aug 13, 2024
Nov 13, 2024
Aug 13, 2024
Apr 22, 2024
Aug 13, 2024
Jan 27, 2023
Aug 13, 2024
Jun 9, 2023
Aug 13, 2024
Feb 9, 2023
Aug 13, 2024
Jan 27, 2023
Apr 22, 2024
Jan 27, 2023
Aug 13, 2024
Jan 27, 2023
Aug 13, 2024
Jan 7, 2025
Aug 13, 2024
Feb 9, 2023
Mar 11, 2024
Jan 3, 2025
Jan 7, 2025
Feb 10, 2025
Aug 13, 2024
Mar 13, 2023
Feb 3, 2025
Feb 3, 2025
Aug 13, 2024
Oct 25, 2024
Dec 23, 2024
Apr 4, 2024
Apr 4, 2024
Apr 22, 2024
Apr 12, 2023
Jan 27, 2023
Jan 27, 2023
Jan 8, 2025
Jan 2, 2025
Aug 13, 2024
Apr 10, 2024
Aug 13, 2024
Jan 27, 2023
Feb 7, 2025
Feb 7, 2025
Aug 13, 2024
Apr 17, 2024
Aug 13, 2024
Jun 15, 2023
Aug 15, 2024
Aug 15, 2024
Aug 13, 2024
Aug 13, 2024
Jan 27, 2023
Jan 27, 2023
Aug 13, 2024
Aug 13, 2024
Jan 2, 2024
Aug 13, 2024
Aug 31, 2023
Apr 26, 2024
Aug 13, 2024
Jun 26, 2024
Aug 13, 2024
Aug 31, 2023
Aug 13, 2024
Apr 22, 2024
Jan 24, 2025
Jan 24, 2025
Feb 14, 2025
Feb 14, 2025
Sep 30, 2024
Sep 30, 2024
Aug 13, 2024
Apr 22, 2024
Aug 13, 2024
Jan 27, 2023
Aug 13, 2024
Jan 27, 2023
Jun 16, 2023
May 3, 2023
May 8, 2023
Jun 26, 2023
Feb 19, 2025
Aug 13, 2024
Apr 11, 2023
Feb 19, 2025
Aug 13, 2024
Apr 4, 2024
Jul 3, 2024
Jul 15, 2024
Jul 15, 2024
Jan 7, 2025
Nov 22, 2023
Aug 13, 2024
Jan 27, 2023
Jan 15, 2025
Aug 14, 2024
Jul 29, 2024
Aug 12, 2024
Jan 13, 2025
Aug 14, 2024
Jan 13, 2025
Aug 8, 2024
Sep 17, 2024
Jan 13, 2025
Sep 13, 2024
Sep 13, 2024
Aug 13, 2024
Apr 22, 2024
Oct 1, 2024
Oct 31, 2024
Apr 22, 2024
Apr 22, 2024
Jan 23, 2024
Apr 28, 2023
Aug 13, 2024
Aug 13, 2024
Feb 9, 2023
Jul 30, 2024
Aug 13, 2024
Feb 9, 2023
Jan 10, 2025
Jan 14, 2025
Aug 13, 2024
Jan 18, 2024
Oct 9, 2023
Jan 15, 2025
Feb 19, 2025
Aug 13, 2024
Mar 5, 2024
Sep 25, 2024
Apr 22, 2024
Sep 25, 2024
Dec 16, 2024
May 15, 2024
Mar 31, 2023
Aug 13, 2024
Jan 18, 2024
Jun 26, 2024
Jun 26, 2024
Aug 13, 2024
Mar 19, 2024
Oct 25, 2024
Oct 25, 2024
Aug 13, 2024
May 8, 2023
Jan 24, 2025
Jan 24, 2025
Aug 13, 2024
Sep 13, 2024
Aug 13, 2024
Apr 4, 2024

HCP Terraform and Terraform Enterprise Go Client

Tests GitHub license GoDoc Go Report Card GitHub issues

The official Go API client for HCP Terraform and Terraform Enterprise.

This client supports the HCP Terraform V2 API. As Terraform Enterprise is a self-hosted distribution of HCP Terraform, this client supports both HCP Terraform and Terraform Enterprise use cases. In all package documentation and API, 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).

Version Information

Almost always, minor version changes will indicate backwards-compatible features and enhancements. Occasionally, function signature changes that reflect a bug fix may appear as a minor version change. Patch version changes will be used for bug fixes, performance improvements, and otherwise unimpactful changes.

Example Usage

Construct a new TFE client, then use the various endpoints on the client to access different parts of the Terraform Enterprise API. The following example lists all organizations.

(Recommended Approach) Using custom config to provide configuration details to the API client

import (
  "context"
  "log"

  "github.com/hashicorp/go-tfe"
)

config := &tfe.Config{
	Address: "https://tfe.local",
	Token: "insert-your-token-here",
  RetryServerErrors: true,
}

client, err := tfe.NewClient(config)
if err != nil {
	log.Fatal(err)
}

orgs, err := client.Organizations.List(context.Background(), nil)
if err != nil {
	log.Fatal(err)
}

Using the default config with env vars

The default configuration makes use of the TFE_ADDRESS and TFE_TOKEN environment variables.

  1. TFE_ADDRESS - URL of a HCP Terraform or Terraform Enterprise instance. Example: https://tfe.local
  2. TFE_TOKEN - An API token for the HCP Terraform or Terraform Enterprise instance.

Note: Alternatively, you can set TFE_HOSTNAME which serves as a fallback for TFE_ADDRESS. It will only be used if TFE_ADDRESS is not set and will resolve the host to an https scheme. Example: tfe.local => resolves to https://tfe.local

The environment variables are used as a fallback to configure TFE client if the Address or Token values are not provided as in the cases below:

Using the default configuration

import (
  "context"
  "log"

  "github.com/hashicorp/go-tfe"
)

// Passing nil to tfe.NewClient method will also use the default configuration
client, err := tfe.NewClient(tfe.DefaultConfig())
if err != nil {
	log.Fatal(err)
}

orgs, err := client.Organizations.List(context.Background(), nil)
if err != nil {
	log.Fatal(err)
}

When Address or Token has no value

import (
  "context"
  "log"

  "github.com/hashicorp/go-tfe"
)

config := &tfe.Config{
	Address: "",
	Token: "",
}

client, err := tfe.NewClient(config)
if err != nil {
	log.Fatal(err)
}

orgs, err := client.Organizations.List(context.Background(), nil)
if err != nil {
	log.Fatal(err)
}

Documentation

For complete usage of the API client, see the full package docs.

Examples

See the examples directory.

Running tests

See TESTS.md.

Issues and Contributing

See CONTRIBUTING.md

Releases

See RELEASES.md