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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pytfc-0.0.6.tar.gz
.
File metadata
- Download URL: pytfc-0.0.6.tar.gz
- Upload date:
- Size: 19.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4b132aa32bca554896ee4091b342dab9c0e3fd5b569ec4c50b5cf9fc570f47d |
|
MD5 | 4cf124bfeab7032e8c1940e2c64f1ab6 |
|
BLAKE2b-256 | 6fb8c8970d6d89bd78d3f961738d528fbc22f01714944a79d92e7484af9fbec6 |
File details
Details for the file pytfc-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: pytfc-0.0.6-py3-none-any.whl
- Upload date:
- Size: 26.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a002324c0766e442b5e1a46ae8652e93bf7ed2793771a85ae2ff5c13cdcf16c5 |
|
MD5 | 987e1b296aa9eeeb4cb40e449e491620 |
|
BLAKE2b-256 | 71549851e7eed07fe5c7493246571d034137d695bd382999cbf2a1a8f784406c |