Terraform task management wrapper for Python
Project description
twrapform
A Python library for running Terraform commands from Python with async support.
Features
- Execute Terraform commands from Python code
- Asynchronous execution support
- Task management with unique IDs
- Customizable task options
- Error handling for Terraform operations
Requirements
- Python 3.10 or higher
- Terraform installed on your system
Installation
Using pip:
pip install twrapform
Usage Example
import asyncio
from twrapform import Workflow
from twrapform.exception import TwrapformError
from twrapform.options import InitTaskOptions, PlanTaskOptions, ApplyTaskOptions, OutputTaskOptions
async def main():
# Create an instance of Twrapform
twrap = Workflow(work_dir="/terraform_rootpath")
# Add Terraform tasks one by one
twrap = twrap.add_task(InitTaskOptions())
# Chain multiple tasks
twrap = (
twrap
.add_task(PlanTaskOptions(var={"var1": 1}))
.add_task(ApplyTaskOptions(var={"var1": 1}))
.add_task(OutputTaskOptions(json=True))
)
# Execute all tasks
results = await twrap.execute()
try:
# Raise errors if any task fails
results.raise_on_error()
except TwrapformError as e:
print(f"Error occurred: {e.message}")
# Output results for successful tasks
for success_task in results.get_success_tasks():
print(success_task.stdout)
if __name__ == "__main__":
asyncio.run(main())
Supported Commands
twrapform currently supports the following Terraform commands:
terraform initterraform planterraform applyterraform outputterraform workspace select
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
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 twrapform-0.0.4.tar.gz.
File metadata
- Download URL: twrapform-0.0.4.tar.gz
- Upload date:
- Size: 18.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07cccd4fd03ecac065226a943ec8d5213e8dd39f20034810f09a4e903a5f486c
|
|
| MD5 |
40ec653c55140448e26a0deda489e257
|
|
| BLAKE2b-256 |
c1a2c81736cd8841fd4a02bcba9b6081e6a5383fcbcd1765122b70553d3dfa87
|
Provenance
The following attestation bundles were made for twrapform-0.0.4.tar.gz:
Publisher:
publish-pypi.yml on minthem/twrapform
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
twrapform-0.0.4.tar.gz -
Subject digest:
07cccd4fd03ecac065226a943ec8d5213e8dd39f20034810f09a4e903a5f486c - Sigstore transparency entry: 264752921
- Sigstore integration time:
-
Permalink:
minthem/twrapform@5c61d4e4af6c217deb4764f4f2c9cdea443cf078 -
Branch / Tag:
refs/tags/0.0.4 - Owner: https://github.com/minthem
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@5c61d4e4af6c217deb4764f4f2c9cdea443cf078 -
Trigger Event:
push
-
Statement type:
File details
Details for the file twrapform-0.0.4-py3-none-any.whl.
File metadata
- Download URL: twrapform-0.0.4-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f7ce891e61d79707c9c6d88fd226e285216778aef4789bb4d23c9aae890a04f
|
|
| MD5 |
f45a9bb9c700ab9419fa537b15ad2e43
|
|
| BLAKE2b-256 |
b7dc986b079df5ee19fc6d0de70571279a2848ec2552d30344d1d6bed395bd5e
|
Provenance
The following attestation bundles were made for twrapform-0.0.4-py3-none-any.whl:
Publisher:
publish-pypi.yml on minthem/twrapform
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
twrapform-0.0.4-py3-none-any.whl -
Subject digest:
6f7ce891e61d79707c9c6d88fd226e285216778aef4789bb4d23c9aae890a04f - Sigstore transparency entry: 264752923
- Sigstore integration time:
-
Permalink:
minthem/twrapform@5c61d4e4af6c217deb4764f4f2c9cdea443cf078 -
Branch / Tag:
refs/tags/0.0.4 - Owner: https://github.com/minthem
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@5c61d4e4af6c217deb4764f4f2c9cdea443cf078 -
Trigger Event:
push
-
Statement type: