Skip to main content

HashiCorp Terraform Cloud API client

Project description

CircleCI

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

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

noos_tf-0.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

noos_tf-0.1.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file noos_tf-0.1.0.tar.gz.

File metadata

  • Download URL: noos_tf-0.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.1

File hashes

Hashes for noos_tf-0.1.0.tar.gz
Algorithm Hash digest
SHA256 083827ed2cd94d6c325a4294ef00afa37bf21191e7a2906bab38953fcd705b3c
MD5 42f0ca88abc4fe65fb597803c6cf873d
BLAKE2b-256 3125f76c9191f9289f89e4e9ab093651b5933de982170ebba31839805dd4eb88

See more details on using hashes here.

File details

Details for the file noos_tf-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: noos_tf-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.1

File hashes

Hashes for noos_tf-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 40be91dc0c8a4969c8a761b1559902b4358498637a30e54226deb6917db6ac18
MD5 71e2d263248f6f7ca97918054cc9490e
BLAKE2b-256 8b8982eb5323277442bccc3239b1be0b5cacb036a39467a8f90d458519f50bc7

See more details on using hashes here.

Supported by

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