A Python wrapper for Terraform
Project description
TerraWeave: A Python Wrapper for Terraform
TerraWeave is a Python library that provides a simple interface for interacting with Terraform. It wraps common Terraform commands such as init, plan, apply, destroy, and workspace management, making it easier to integrate Terraform into Python-based workflows.
Features
- Initialize a Terraform working directory (
terraform init). - Generate and show execution plans (
terraform plan). - Apply changes to reach the desired state (
terraform apply). - Destroy Terraform-managed infrastructure (
terraform destroy). - Retrieve Terraform output variables (
terraform output). - Manage Terraform workspaces:
- List workspaces (
terraform workspace list). - Show the current workspace (
terraform workspace show). - Create a new workspace (
terraform workspace new). - Select a workspace (
terraform workspace select). - Delete a workspace (
terraform workspace delete).
- List workspaces (
Installation
Pip
pip install TerraWeave
From source
Clone the repository to your local machine:
git clone https://github.com/brains93/TerraWeave.git
cd TerraWeave
Ensure you have Python 3.7+ installed, along with Terraform installed and available in your system's PATH.
Usage Example: Basic Usage
NOTE: the class uses python logging to print the output to stdout, this can be redirectedto a file using the same logging library
from TerraWeave import TerraformWrapper
# Path to the directory containing Terraform configuration files
working_dir = "/path/to/terraform/config"
# Initialize the TerraformWrapper
tf = TerraformWrapper(working_dir)
# Initialize Terraform
print("Initializing Terraform...")
tf.init()
# Generate a plan
print("Generating Terraform plan...")
tf.plan()
# Apply the changes
print("Applying Terraform changes...")
tf.apply()
# Destroy the infrastructure
print("Destroying Terraform-managed infrastructure...")
tf.destroy()
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file terraweave-0.1.6.tar.gz.
File metadata
- Download URL: terraweave-0.1.6.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96ef69a60b6e776cca2d9b77d97e44318a109bf0c4d52d43c06be2a1378107ed
|
|
| MD5 |
c48d25dcc53efd60ae9a1234696caaa9
|
|
| BLAKE2b-256 |
9e5df6fb26ee32da7b211ad46e2917af2f9b1d9b01f374a06b7529f1e790de29
|
File details
Details for the file terraweave-0.1.6-py3-none-any.whl.
File metadata
- Download URL: terraweave-0.1.6-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3662ea399b033ce864e0df24df30ee0c6f0a74e9a68e38f381baeaa1a2d557ba
|
|
| MD5 |
d287a3ddfa4c00e5aac50ca9351ada12
|
|
| BLAKE2b-256 |
9c4cd328cdd00ed2270c25a4f9b0bfaccc6b78e3b6d87858c47c4967d3e88b92
|