Skip to main content

A small client library for the Terraform Enterprise REST API.

Project description

Pyterprise

This is a small Python client library for Terraform Enterprise with helper functions to abstract usage of the HTTP API - this is a work in progress and likely not all functionality of the API has (or will) be ported over - but most common uses will attempted to be covered here.

The methods used are straightforward and relatively self documenting so I won't have too much uses covered here.

Usage:

First import the module and authenticate using the init method, you can retrieve a token from the terraform enterprise UI.

import pyterprise


tfe_token = 'TOKENHERE'
client = pyterprise.TerraformAPI()

# Supply your token as a parameter and the url for the terraform enterprise server.
client.init(token=tfe_token, url='Endpoint for TFE')

Once initialized, you should be able to run various methods for accessing the API, most of the methods are basic python implementations of http requests that will simply return the json response content as a string. Here is some example usage that you can combine with the authentication example below:

# returns a list of all workspace IDs for a given organization
client.list_workspace_ids(organization='<org-name>')

# returns the most current statefile of a given workspace
client.get_workspace_current_statefile(workspace_id='example')

# run the terraform in a given workspace
client.run_terraform_workspace(workspace_id='<workspace id>', message='test of api client')

# get terraform plan information for a given workspace
client.get_terraform_plan(plan_id='test_id')

Please read the main code here for more methods to use for the API.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyterprise-0.0.1.tar.gz (3.1 kB view hashes)

Uploaded Source

Built Distribution

pyterprise-0.0.1-py3-none-any.whl (4.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page