Terraform Cloud Client
An API client for HashiCorp's Terraform Cloud
Installation
$ pip install terraform-cloud-client
This client is only tested on python 3.7
Usage as a library
Set up:
>>> import tfc
>>> client = tfc.TerraformClient("my_api_token", "my_organization", "my_workspace")
Get Terraform variables:
>>> variables = client.get_variables()
>>> variables
{
'my_username': <TerraformVariable id='var-someid1', name='my_username', value='john_doe'>,
'my_password': <TerraformVariable id='var-someid2', name='my_password', sensitive>,
}
>>> username_variable = variables['my_username']
>>> username_variable.id
'var-someid1'
>>> username_variable.name
'my_username'
>>> username_variable.value
'john_doe'
Change the value of a variable:
>>> client.update_variable(variable_id=username_variable.id, new_value='jane_doe')
Trigger a run:
>>> run = client.create_run('My message')
>>> run.id
'run-someid'
>>> run.url # Go here in a web browser to view the run
'https://app.terraform.io/app/my_organization/workspaces/my_workspace/runs/run-someid'
Usage as a command line tool
Installing this via pip also installs a tfc command line tool
$ tfc --help
usage: tfc [-h] [--message MESSAGE]
organization workspace [name=value [name=value ...]]
Trigger a Terraform Cloud run
positional arguments:
organization The name of your organization in Terraform Cloud
workspace The name of your workspace in Terraform Cloud
name=value Set terraform variable NAME to VALUE before creating
the run
optional arguments:
-h, --help show this help message and exit
--message MESSAGE, -m MESSAGE
The message to be associated with this run
Put your API token in the TERRAFORM_CLOUD_TOKEN environment variable
So for example:
$ tfc my_organization my_workspace foo=baz --message="Reticulating splines"
Updated 'foo' from 'bar' to 'baz'
Created run run-g6SmSsLVKg71yeNw - check status at: https://app.terraform.io/app/my_organization/workspaces/my_workspace/runs/run-g6SmSsLVKg71yeNw
Metadata
Release files for terraform-cloud-client 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| terraform-cloud-client-0.0.2.tar.gz | 4.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| terraform_cloud_client-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.3 kB
Release files / terraform-cloud-client-0.0.2.tar.gz
| Download URL | terraform-cloud-client-0.0.2.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3550007923f4fc87efa980da1006f6cca04b8a12a7b34f167d5cc7de21ccded9
|
|
BLAKE2b-256 checksum How to use checksums |
b2ddb54a69f20030421c3c78e38c911d2b0ee26d7cdb245044e5dc9a6e173a05
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.3
|
Release files / terraform_cloud_client-0.0.2-py3-none-any.whl
| Download URL | terraform_cloud_client-0.0.2-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f221a5dfea1a5f138394c31aa0212451f6123b5a8873205bc5aec8875e42554e
|
|
BLAKE2b-256 checksum How to use checksums |
ee471b135960ab5d60c58205533decd503b87dcced5e1419ef6b17643efd7e48
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.3
|