Skip to main content
pipeline status

A simple Terraform wrapper to use variable definition files if they match the workspace name.

Rationale

With workspaces, one can use the same module in different environments with minor changes like different domain name, size of a cluster, instance type. One can use variable definition files to store the values for each workspace in a dedicated file. This wrapper replaces the following:

terraform workspace select prod
terraform plan -var-files=prod.tfvars -out tfplan

to:

terraform workspace select prod
tf plan -out tfplan

Installation

python3 -m pip install terraformation

The wrapper is a single Python3 script with no external dependencies. If you prefer, you can download the tf.py and use that instead.

Usage

Replace terraform with tf. In case there’s a variable definitions file (that ends with .tfvars) that matches the current workspace name (if the current workspace name is prod and a file named prod.tfvars exists) than a -var-file=prod.tfvars argument is added to the relevant commands (like plan and import). All other arguments are kept as they were. Similarly, if a directory exists with the same name as the workspace, for all the files inside that directory that end with .tfvars, a -var-file argument is added. For example: -var-file=prod/a.tfvars and -var-file=prod/b.tfvars.

By default tf invokes terraform, but if you’re using a different tool (like OpenTofu) you can set the TF_CLI environment variable to that tool’s name. If you wish to know the exact command tf is running set the TF_DEBUG environment variable to 1 and the command will printed before it’s invoked.

License

This software is licensed under the MIT license (see the LICENSE.txt file).

Author

Nimrod Adar, contact me or visit my website. Patches are welcome via git send-email. The repository is located at: https://git.shore.co.il/nimrod/.

Metadata

Release files for terraformation 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for terraformation 0.3.1
File Size Uploaded
terraformation-0.3.1.tar.gz 4.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for terraformation 0.3.1
File Interpreter ABI Platform
terraformation-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.7 kB

Release files / terraformation-0.3.1.tar.gz

Download URL terraformation-0.3.1.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c676a2c9b7121249eda3c701e8bc0f8e8a2880560c15a1f40965846d5cf9e5fa
BLAKE2b-256 checksum
How to use checksums
41a3f470507e0145e1a1784bc7990ce308d835e32ee01a819d09a9aed41645c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.10.0 requests/2.27.1 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.6.8

Release files / terraformation-0.3.1-py3-none-any.whl

Download URL terraformation-0.3.1-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b56536612f4e901422eafeada4ec2b84f15eb83419757503b25164585e4e7152
BLAKE2b-256 checksum
How to use checksums
a3225b3000dfd9afcb332b529465207308dcdd701dbf6db3ede6933ff4de865b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.10.0 requests/2.27.1 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.6.8

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page