Coder Social home page Coder Social logo

sharathrnair87 / go-tfe Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hashicorp/go-tfe

0.0 0.0 0.0 2.92 MB

Terraform Cloud/Enterprise API Client/SDK in Golang

Home Page: https://pkg.go.dev/github.com/hashicorp/go-tfe

License: Mozilla Public License 2.0

Shell 0.70% Go 99.16% Makefile 0.06% HCL 0.07%

go-tfe's Introduction

Terraform Cloud/Enterprise Go Client

Tests GitHub license GoDoc Go Report Card GitHub issues

The official Go API client for Terraform Cloud/Enterprise.

This client supports the Terraform Cloud V2 API. As Terraform Enterprise is a self-hosted distribution of Terraform Cloud, this client supports both Cloud and 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 Terraform Cloud or Terraform Enterprise instance. Example: https://tfe.local
  2. TFE_TOKEN - An API token for the Terraform Cloud 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.

API Coverage

This API client covers most of the existing Terraform Cloud API calls and is updated regularly to add new or missing endpoints.

  • Account
  • Agents
  • Agent Pools
  • Agent Tokens
  • Applies
  • Audit Trails
  • Changelog
  • Comments
  • Configuration Versions
  • Cost Estimation
  • Feature Sets
  • Invoices
  • IP Ranges
  • Notification Configurations
  • OAuth Clients
  • OAuth Tokens
  • Organizations
  • Organization Memberships
  • Organization Tags
  • Organization Tokens
  • Plan Exports
  • Plans
  • Policies
  • Policy Checks
  • Policy Sets
  • Policy Set Parameters
  • Private Registry
    • Modules
      • No-Code Modules
    • Providers
    • Provider Versions and Platforms
    • GPG Keys
  • Projects
  • Runs
  • Run Events
  • Run Tasks
  • Run Tasks Integration
  • Run Triggers
  • SSH Keys
  • Stability Policy
  • State Versions
  • State Version Outputs
  • Subscriptions
  • Team Access
  • Team Membership
  • Team Tokens
  • Teams
  • Test Runs
  • User Tokens
  • Users
  • Variable Sets
  • Variables
  • VCS Events
  • Workspaces
  • Workspace-Specific Variables
  • Workspace Resources
  • Admin
    • Module Sharing
    • Organizations
    • Runs
    • Settings
    • Terraform Versions
    • OPA Versions
    • Sentinel Versions
    • Users
    • Workspaces

Examples

See the examples directory.

Running tests

See TESTS.md.

Issues and Contributing

See CONTRIBUTING.md

Releases

See RELEASES.md

go-tfe's People

Contributors

brandonc avatar sebasslash avatar annawinkler avatar laurenolivia avatar ryanuber avatar chrisarcand avatar uturunku1 avatar mrinalirao avatar nfagerlund avatar hs26gill avatar omarismail avatar dependabot[bot] avatar uk1288 avatar hashimoon avatar juliannatetreault avatar lafentres avatar dsa0x avatar glennsarti avatar thrashr888 avatar jarrettspiker avatar barrettclark avatar byronwolfman avatar radditude avatar mwudka avatar davidcelis avatar rberecka avatar mpminardi avatar hashicorp-copywrite[bot] avatar mjyocca avatar jeevanragula avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.