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.0 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.0.tar.gz (52.2 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.0-py3-none-any.whl (38.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tfutility-1.2.0.tar.gz
  • Upload date:
  • Size: 52.2 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.0.tar.gz
Algorithm Hash digest
SHA256 bb40528a03cb7543ed25db62d77af1033b9f2186c2393cbdcdc12fd7856f2ef9
MD5 90e5961db7b2c1c12c97703412a27170
BLAKE2b-256 8a11254217eecfab62545ebf819a73dcc1ea0877810120e4abf22970f97849f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for tfutility-1.2.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: tfutility-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 38.2 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5402b2e6440e2706e8e851147f417aebec1aa193e7d609e4bce2b3e099c600af
MD5 4ea36f2699596d04ca75111ca5497020
BLAKE2b-256 24d5c81a56282ebf94d04f276b330407b8b7a7e3c733e97e2cf8dee9403520fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for tfutility-1.2.0-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