Skip to main content

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


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.2.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

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

terraformer-0.2.0-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file terraformer-0.2.0.tar.gz.

File metadata

  • Download URL: terraformer-0.2.0.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.2

File hashes

Hashes for terraformer-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0887b8ea1080d5311170e5e315f56d6977df1dbab5a887d2ce2c88e05a3e94fe
MD5 508522b9c63174ca62b2dbd72d55a857
BLAKE2b-256 e879e0b3c154d0abb252517c6a91454f97c5c0ddd9810ee9508a2570e33a79f1

See more details on using hashes here.

File details

Details for the file terraformer-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: terraformer-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.2

File hashes

Hashes for terraformer-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6f930601aa0c3d3f7e357e45c87815557a1b5de146d369a6077211d0af1dd855
MD5 050d08bb050ccd275111be3ef6ebdc78
BLAKE2b-256 e2b93d94f7e91f1a4ddb587a3edce8d0194858651b20dc16ca47f8054f971643

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