Skip to content

Automates formatting and linting your terraform code. Better than `terraform fmt`.

License

Notifications You must be signed in to change notification settings

davenicoll/terratidy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Automates formatting and linting your terraform code. Better than `terraform fmt`.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages