Skip to main content

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

Project description

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.

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/.

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

terraformation-0.1.0.tar.gz (3.7 kB view hashes)

Uploaded Source

Built Distribution

terraformation-0.1.0-py3-none-any.whl (4.8 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