Skip to main content

TfUtility

Validate

Documentation:

tfutility allows performing commands on terraform/tofu files. This commands can be different things. Currently, there are possibilities to check if a module block has remote sources. Or import or moved blocks have creation dates on them.

It also allows TF-Stack Developers to swap the sources of marked modules.

For all of these Functions, show the Samples Below or read the Documentation

Setup

Install via PIP

Install tfutility via pip

$ pip install tfutility

Run tfutility in command line

$ tfutility

for detailed Examples visit the Documentation

Use with Docker

docker run -it --rm -v $(pwd):/workspace ghcr.io/eieste/tfutility:1.2.1 forcedremotesource /workspace

Use with pre-commit

Create a .pre-commit-config.yaml with the following content.

repos:
  - repo: https://github.com/eieste/tfutility/
    rev: 1.1.1
    hooks:
      - id: check-forcedremotesource
      - id: check-importdate
      - id: check-moveddate

Its possible to attach the suffix -docker to each hook to use precommit docker hooks

Autocompletion

Run the following command to setup a bash autocompletion for this command

register-python-argcomplete tfutilty > /etc/bash_completion.d/tfutilty

Quick-Reference

The following Options are currently available

@importdate

The importdate decorator should help you to keep your code clean. You should be able to delete imports after the stack has been successfully rolled out. this decorator is useful to avoid removing import blocks too early or forgetting them

Example:

    # @importdate(create="01-12-1970", expire="05-01-1971)
    import {
        ...
    }

Execute the following command to check if the import was "expired"

tfutility importdate /workspace

you can also overwrite the expire date with your own duration like:

tfutility importdate --expire-after 60 /workspace

The --expire-after value is in Days.

If --allow-failure is not set the Application wil exit with exitcode 1 and without --silent it logs all expired imports

@moveddate

This has the same Reason like @importdate

Decorator in Terraform

    # @moveddate(create="01-12-1970", expire="05-01-1971)
    moved {
        ...
    }

Execute the following command to check if the moved was "expired"

tfutility moveddate /workspace

@sourceswap

This command allows to swap between remote and local sources.

    # @sourceswap(remote_version="0.0.1", remote_source="example.com/examplemodule/local", source="../../examplemodule")
    module {
        source = "../../examplemodule"
    }

To Swap all Sources in your workspace you can execute the following command

tfutility sourceswap --swap-to local /workspace
tfutility sourceswap --swap-to remote /workspace

@forcedremotesource

Decorator in Terraform

    # @forceremotecheck
    module {
        source = "../
    }

Execute the following command to check if all module blocks has an remote source.

tfutility forcedremotesource /workspace

Release files for tfutility 1.2.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 tfutility 1.2.1
File Size Uploaded
tfutility-1.2.1.tar.gz 52.3 kB Details

Built distribution (wheel)

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

Total release size: 90.4 kB

Release files / tfutility-1.2.1.tar.gz

Download URL tfutility-1.2.1.tar.gz
Size 52.3 kB
Tags Source
SHA-256 checksum
How to use checksums
20c483afea7b0a90f8438fb7793ea8c6f79cb4932310b5e6985e5f85185a707c
BLAKE2b-256 checksum
How to use checksums
6b9ab6381985a0d817ce339bf72778e10d9549059f6b9f53fef739315171afc0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 19, 2024.

Transparency log

Release files / tfutility-1.2.1-py3-none-any.whl

Download URL tfutility-1.2.1-py3-none-any.whl
Size 38.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
92a0827eb63a9759efeb37d924f8e60efd37d28e9f11104477b38ed0829e3511
BLAKE2b-256 checksum
How to use checksums
31343d299cd9f2682f0b428dc6eba2b3965846f25515370227a37a8a17c9adaa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 19, 2024.

Transparency log

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.11

2 release files

1.0.10

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

0.0.1

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