Noos Energy Terraform Client
A Python client wrapping up HashiCorp's Terraform Cloud API.
Installation
Package available from the PyPi repository:
$ pip install noos-tf
Usage as a library
Import the namespace within your project,
import os
import noos_tf
# Instantiate client
tf_client = noos_tf.TerraformClient()
# Authenticate client
tf_client.set_auth_header(token=os.getenv("TERRAFORM_TOKEN"))
Then query directly from the Terraform Cloud API ; as a example:
- a workspace ID:
tf_client.get_workspace_id("myOrganisation", "myWorkspace")
- the variable IDs from a given workspace:
tf_client.get_variable_ids("myOrganisation", "myWorkspace")
The library offers as well some helper functions for more involved workflows, such as:
- updating a variable value:
noos_tf.update_workspace_variable(
"myOrganisation",
"myWorkspace",
os.getenv("TERRAFORM_TOKEN"),
"myVariable",
"new_value",
)
- running and applying a plan:
noos_tf.run_workspace_plan(
"myOrganisation",
"myWorkspace",
os.getenv("TERRAFORM_TOKEN"),
"Test run",
)
Usage as a command line tool
The above helper functions could be accessed directly from the command line.
$ noostf
Usage: noostf [--core-opts] <subcommand> [--subcommand-opts] ...
Subcommands:
run Run a plan in Terraform cloud.
update Update variable in Terraform cloud.
Development
Make sure uv has been installed and pre-configured,
This project is shipped with a Makefile, which is ready to do basic common tasks.
$ make
help Display this auto-generated help message
update Lock and install build dependencies
clean Clean project from temp files / dirs
format Run auto-formatting linters
install Install build dependencies from lock file
lint Run python linters
test Run pytest with all tests
package Build project wheel distribution
release Publish wheel distribution to PyPi
Release files for noos-tf 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| noos_tf-0.1.0.tar.gz | 4.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| noos_tf-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.2 kB
Release files / noos_tf-0.1.0.tar.gz
| Download URL | noos_tf-0.1.0.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
083827ed2cd94d6c325a4294ef00afa37bf21191e7a2906bab38953fcd705b3c
|
|
BLAKE2b-256 checksum How to use checksums |
3125f76c9191f9289f89e4e9ab093651b5933de982170ebba31839805dd4eb88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.1
|
Release files / noos_tf-0.1.0-py3-none-any.whl
| Download URL | noos_tf-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
40be91dc0c8a4969c8a761b1559902b4358498637a30e54226deb6917db6ac18
|
|
BLAKE2b-256 checksum How to use checksums |
8b8982eb5323277442bccc3239b1be0b5cacb036a39467a8f90d458519f50bc7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.1
|