Skip to main content

Python HTTP client library for Terraform Cloud/Enterprise API.

Project description

pytfc

Python HTTP client library for the Terraform Cloud and Terraform Enterprise API.

import pytfc
client = pytfc.Client(org='my-tfe-org')
client.workspaces.create(name='aws-base-vpc-dev')
client.set_ws(name='aws-base-vpc-dev')
client.workspace_variables.create(key='AWS_ACCESS_KEY_ID', value='ABCDEFGHIJKLMNOPQRST', category='env', sensitive='true')
client.workspace_variables.create(key='AWS_SECRET_ACCESS_KEY', value='ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCD', category='env', sensitive='true')

Usage

A client object must be instantiated with certain parameters. The parameters can be specified as environment variables or directly as function arguments. The only parameter required at the time a client is instantiated is the API token. A hostname is also required if you are using TFE, and if a hostname is not specified it is assumed you are using TFC (app.terraform.io). Depending on what level you are working at, mainly Organization-level vs. Workspace-level, you can optionally set some of the other parameters either at the time the client is instantiated or after the fact.

Instantiating a Client

With environment variables:

os.environ['TFE_HOSTNAME']='tfe.whatever.com'
os.environ['TFE_TOKEN']='abcdefghijklmn.atlasv1.opqrstuvwxyz012345678987654321abcdefghijklmnopqrstuvwxyz01234567890'

client = pytfc.Client(org='my-existing-tfe-org')

Directly as function arguments:

client = pytfc.Client(hostname='tfe.whatever.com', token='abcdefghijklmn.atlasv1.opqrstuvwxyz012345678987654321abcdefghijklmnopqrstuvwxyz01234567890', org='my-existing-tfe-org')

Setting the Organization and Workspace when a client is instantiated:

client = pytfc.Client(org='my-existing-tfe-org', ws='my-existing-tfe-ws')

Assumes the TFE_HOSTNAME and TFE_TOKEN environment variables are set.

Setting the Organization and Workspace after a client is instantiated:

client = pytfc.Client()
client.set_org(name='my-existing-tfe-org')
client.set_ws(name='my-existing-tfe-ws')

Assumes the TFE_HOSTNAME and TFE_TOKEN environment variables are set.


See the docs for more details and examples on usage.

 


Note: this is repository is not officially supported or maintained by HashiCorp.

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

pytfc-0.0.18.tar.gz (27.6 kB view details)

Uploaded Source

Built Distribution

pytfc-0.0.18-py3-none-any.whl (42.4 kB view details)

Uploaded Python 3

File details

Details for the file pytfc-0.0.18.tar.gz.

File metadata

  • Download URL: pytfc-0.0.18.tar.gz
  • Upload date:
  • Size: 27.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for pytfc-0.0.18.tar.gz
Algorithm Hash digest
SHA256 76fbb55a6ff449dd6c4e68d9897afa256646581855eb87a446d2977377451e15
MD5 619e0c47b277e1dac7753c5ca6fbd786
BLAKE2b-256 dfac2abf2bf2e6e1b916f240cbcfb20c147f8a254a09d4d620739c00f15241af

See more details on using hashes here.

File details

Details for the file pytfc-0.0.18-py3-none-any.whl.

File metadata

  • Download URL: pytfc-0.0.18-py3-none-any.whl
  • Upload date:
  • Size: 42.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for pytfc-0.0.18-py3-none-any.whl
Algorithm Hash digest
SHA256 1557a3027d2c93807b955efa7ea888a68e33b3e949eb4be100264e592ca3f3e8
MD5 fe4e51f84115a9ba0dc8ca6877a6f2b2
BLAKE2b-256 a32fed685346c67ee27ddafe3a0f4e5402d93e5dff73c1d6105970dfd23a1292

See more details on using hashes here.

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