Skip to main content

Tfrunner

Welcome to tfrunner, a cli tool to run terraform commands with the following facilities:

  • Multi-project support
  • Automation support
  • Remote backend
  • GitLab secrets pulling

Installation

Since tfrunner is a cli tool, the recommended installation is using pipx.

Please ensure you have a compatible python >= 3.12 version.

Install with: pipx install tfrunner

Usage

Requirements: tfrunner expects the following binaries to be installed:

  • terraform: tfrunner is a wrapper on top of terraform
  • git: when using the --git-sandbox flag, ensure you have git installed and that you are running the command in a git project

To use it to manage multiple projects, create a yaml file configuring each.

Here is an example file, let's name it tfrunner.yaml:

flavour: terraform # Can use tofu

state_backend:
  kind: gitlab
  spec:
    url: https://gitlab.com
    project_id: 12345678
    token_var: GITLAB_TOKEN

secrets_backend:
  kind: gitlab
  spec:
    url: https://gitlab.com
    project_id: 12345678
    token_var: GITLAB_TOKEN

tfvars:
  gitlab_token: $GITLAB_TOKEN

projects:
  dev: # Reflects name of the environment
    path: ../infra/dev
    state_name: dev
    # Inner environment gets added (and overrides colliding vars) with global env vars
    # env vars take precedence over secrets
    tfvars:
      doppler_token: $DOPPLER_TOKEN
    # Inner secrets backend takes precendence
    secrets_backend:
      kind: doppler
      spec:
        project: my-project
        config: dev
        token_var: DOPPLER_TOKEN

Now you can run tfrunner as you would run any regular terraform command (options are also included). You need only to be wary of two additional arguments that are needed:

  • --project: name of your project, as specified in your config file.
  • --config_path: path to your configuration file. By default it will look for a tfrunner.yaml file in the current folder

As examples, for the great-project in our example tfrunner.yaml file, you could run:

tfrunner init --project great-project
tfrunner fmt --project great-project
tfrunner validate --project great-project
tfrunner plan --project great-project
tfrunner apply --project great-project
tfrunner destroy --config_path tfrunner.yaml --project great-project

The --config_path is optional in the tfrunner destroy command, as tfrunner will by default assume its path to be tfrunner.yaml.

Usage with git-sandboxes

tfrunner init --project great-project --git-sandbox
tfrunner plan --project great-project --git-sandbox
tfrunner apply --project great-project --git-sandbox
tfrunner destroy --project great-project --git-sandbox

Local development

Requirements:

  • uv installed
  • terraform installed
  • git installed
  1. Install virtual environment: uv sync --all-groups

TODO:

  • Make tfrunner plan generate a plan file by default
  • Make tfrunner apply use that plan file by default

Release files for tfrunner 0.12.5

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

Source distribution (sdist)

Source distribution for tfrunner 0.12.5
File Size Uploaded
tfrunner-0.12.5.tar.gz 10.0 kB Details

Built distribution (wheel)

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

Total release size: 27.7 kB

Release files / tfrunner-0.12.5.tar.gz

Download URL tfrunner-0.12.5.tar.gz
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
dfb708724f3301fbe704785e46f7c3d7ede0328859aea516e9807fff0dda0070
BLAKE2b-256 checksum
How to use checksums
36e57085c6dfe803be260c0aceb97bf77d2448c8c1d62528578150233eb74dda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.17

Release files / tfrunner-0.12.5-py3-none-any.whl

Download URL tfrunner-0.12.5-py3-none-any.whl
Size 17.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
14370ace8f5990b8015deb72b7145da8a1f90586c7d3521e038cc073ee7efa84
BLAKE2b-256 checksum
How to use checksums
2c11e3280a9ca7fe08f3821ce876e37e424810d9235eeef61a062a02ca21f8eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.17

Release history Release notifications | RSS feed

This release

0.12.5 This release

2 release files

0.12.4

2 release files

0.12.3

2 release files

0.12.2

2 release files

0.12.1

2 release files

0.12.0

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.5.0

2 release files

0.4.0

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