Skip to main content

A python library

Project description


terraformer is a Python wrapper around the Terraform CLI.


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="./")

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():

The plan step can be skipped if you are auto approving.

from terraformer import Workspace

workspace = Workspace(path="./")
results, apply_log = workspace.apply(auto_approve=True)

There is also the capability to parse an existing plan JSON and create a plan object with the sensitive and unknown attributes sanitized in the output.

  import json

  plan_from_json = TerraformPlan("", "tests/terraform/plans/sensitive_plan.json", False)
  for address, resource_change in plan_from_json.changes:
    print(f"address: {address}\n")


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.3.1.tar.gz (38.9 kB view hashes)

Uploaded Source

Built Distribution

terraformer-0.3.1-py3-none-any.whl (39.4 kB view hashes)

Uploaded Python 3

Supported by

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