A collection of pre-commit hooks for automating code quality, security, and documentation checks for Terraform, OpenTofu, and Terragrunt configurations.
pre-commit-terraform is a collection of Git hooks for the pre-commit framework that automates code quality, security, and documentation checks for Terraform, OpenTofu, and Terragrunt configurations. It helps infrastructure developers maintain consistent, secure, and well-documented code by running automated checks before commits, reducing errors and enforcing best practices.
Infrastructure engineers, DevOps practitioners, and platform teams who use Terraform, OpenTofu, or Terragrunt for infrastructure-as-code and want to automate code quality and security checks in their development workflow.
Developers choose pre-commit-terraform because it bundles essential validation, security scanning, and documentation tools into a single, easy-to-integrate solution that works seamlessly with Git hooks and CI/CD pipelines, saving time and ensuring consistency across teams.
pre-commit git hooks to take care of Terraform configurations 🇺🇦
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Bundles essential tools like terraform fmt, TFLint, Trivy, and terraform-docs into a unified pre-commit workflow, saving setup time and ensuring consistency across checks.
Works seamlessly with Terraform, OpenTofu, and Terragrunt, and allows custom binary paths via environment variables, making it versatile for different IaC setups.
Can be run locally via pre-commit, in CI/CD pipelines, as a Docker container, or standalone, adapting to various development and deployment environments.
Includes hooks for auto-generating Terraform module documentation with terraform-docs and estimating infrastructure costs with Infracost, enhancing maintainability and financial oversight.
Requires installing and updating numerous third-party tools (e.g., tflint, trivy, infracost), which is tedious and error-prone, especially on Windows or in restricted networks, as shown in the lengthy installation instructions.
Hooks like checkov and terraform_tfsec are marked deprecated, and the README warns of planned breaking changes in v2.0 for terraform_providers_lock, potentially disrupting existing workflows.
The project explicitly advises against using the pre-built Docker image for security reasons and recommends building your own, adding maintenance burden for teams with strict compliance requirements.
Hooks such as terraform_providers_lock can be slow and resource-intensive, requiring fine-tuning of parallelism settings, and may not scale well for repositories with hundreds of Terraform modules.