Skip to content

Latest commit

 

History

History
54 lines (37 loc) · 2.96 KB

readme.md

File metadata and controls

54 lines (37 loc) · 2.96 KB

TerraTidy

terratidy is a powerful tool designed to format and lint your Terraform code, ensuring it adheres to best practices. By analyzing your code, terratidy can identify common issues and automatically fix them, making your configurations cleaner, more consistent, and easier to maintain. Forked from the AVMFIX tool.

While many issues can be resolved automatically, some may require manual adjustments. Following established best practices, such as proper directory structures, naming conventions, and clear documentation, will help you maintain high-quality Terraform modules.

terratidy can fix the following issues:

Installation

go install github.com/davenicoll/terratidy@latest

How to use

To use terratidy, open a shell or terminal and run the following command:

terratidy -folder /path/to/your/terraform/module

Replace /path/to/your/terraform/module with the path to the directory containing your Terraform module.

Pre-commit hook

You can also use terratidy in your pre-commit config to enforce consistent standards in your repositories.

- hooks:
    - id: terratidy
      name: terratidy
      entry: /usr/bin/env bash -c 'for dir in $(git diff --cached --name-only --diff-filter=ACM | grep ".tf$" | xargs -n1 dirname | sort -u); do terratidy --folder "$dir"; done'
      language: script
      files: \.tf$
  repo: local

The tool will analyze the specified directory and automatically apply fixes for any issues it identifies. If the process completes successfully, you'll see the message "Tidy completed successfully." If an error occurs during the process, terratidy will display an error message.

Keep in mind that terratidy may not be able to resolve all issues automatically. Manual intervention may be required for some problems.

Provider Agnostic

terratidy is provider-agnostic, seamlessly supporting AWS, Azure, Google Cloud Platform, and more.