A python library
Project description
terraformer
terraformer is a Python wrapper around the Terraform CLI.
Usage
Quick Start
terraformer usage centers around the Workspace object, which can be used to run the typical Terraform commands in that workspace. Just like with the CLI you have to initialize the workspace before you can run plans or applies.
from terraformer import Workspace
workspace = Workspace(path="./")
workspace.init()
results, plan = workspace.plan()
if !results.successful:
raise Exception(f"Terraform run failed without output: {results.stdout}")
if plan.deletions > 0:
raise Exception("Deletions not expected from this plan")
results, apply_log = workspace.apply(plan_path=plan.plan_path, auto_approve=True)
if !results.successful:
print("Terraform Apply was not successful.")
for resource_name, resource_data in apply_log.resources.items():
print(f"${resource_name}: ${resource['message']}")
for output_name, output_data in apply_log.outputs.items():
print(f"{output_name}:\n")
print(yaml.dumps(output_data))
print("\n\n\n")
The plan step can be skipped if you are auto approving.
from terraformer import Workspace
workspace = Workspace(path="./")
workspace.init()
results, apply_log = workspace.apply(auto_approve=True)
Installation
terraformer can be installed with pip.
pip install terraformer
In addition to terraformer you should have the Terraform binary installed on your system.
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
terraformer-0.1.0.tar.gz
(10.8 kB
view hashes)
Built Distribution
Close
Hashes for terraformer-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3318bfd582d2922160a9784cc0fde753898b83e76dd0d42b7465fefb3d92b43d |
|
MD5 | bbf0504f1432cee3e96d075ceb396ab5 |
|
BLAKE2b-256 | f3b0a3028f037d09bb4c9d36384263dc5f858a7e857018e2553fb0ca27134c74 |