Skip to main content

TfUtility provides different tools for Terraform Developers

Project description

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

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

tfutility-1.2.1.tar.gz (52.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tfutility-1.2.1-py3-none-any.whl (38.1 kB view details)

Uploaded Python 3

File details

Details for the file tfutility-1.2.1.tar.gz.

File metadata

  • Download URL: tfutility-1.2.1.tar.gz
  • Upload date:
  • Size: 52.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for tfutility-1.2.1.tar.gz
Algorithm Hash digest
SHA256 20c483afea7b0a90f8438fb7793ea8c6f79cb4932310b5e6985e5f85185a707c
MD5 eef1393564d363085dd6b11893fbfcce
BLAKE2b-256 6b9ab6381985a0d817ce339bf72778e10d9549059f6b9f53fef739315171afc0

See more details on using hashes here.

Provenance

The following attestation bundles were made for tfutility-1.2.1.tar.gz:

Publisher: pypi.yml on eieste/tfutility

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tfutility-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: tfutility-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 38.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for tfutility-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 92a0827eb63a9759efeb37d924f8e60efd37d28e9f11104477b38ed0829e3511
MD5 967381a60ac2653eaf6d63a59df3d5a9
BLAKE2b-256 31343d299cd9f2682f0b428dc6eba2b3965846f25515370227a37a8a17c9adaa

See more details on using hashes here.

Provenance

The following attestation bundles were made for tfutility-1.2.1-py3-none-any.whl:

Publisher: pypi.yml on eieste/tfutility

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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