{"id":25021004,"url":"https://github.com/excoriate/terraform-precommit-hooks","last_synced_at":"2026-02-23T08:02:31.119Z","repository":{"id":41401599,"uuid":"352523060","full_name":"Excoriate/terraform-precommit-hooks","owner":"Excoriate","description":"🚀 Set of simple, straightforward and easy-to-understand terraform hooks","archived":false,"fork":false,"pushed_at":"2021-07-30T06:39:58.000Z","size":906,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-25T03:42:59.255Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Excoriate.png","metadata":{"files":{"readme":"readme.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null}},"created_at":"2021-03-29T05:10:01.000Z","updated_at":"2021-07-30T06:39:10.000Z","dependencies_parsed_at":"2022-09-16T13:51:23.319Z","dependency_job_id":null,"html_url":"https://github.com/Excoriate/terraform-precommit-hooks","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/Excoriate/terraform-precommit-hooks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Excoriate%2Fterraform-precommit-hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Excoriate%2Fterraform-precommit-hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Excoriate%2Fterraform-precommit-hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Excoriate%2Fterraform-precommit-hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Excoriate","download_url":"https://codeload.github.com/Excoriate/terraform-precommit-hooks/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Excoriate%2Fterraform-precommit-hooks/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29739756,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-23T07:44:07.782Z","status":"ssl_error","status_checked_at":"2026-02-23T07:44:07.432Z","response_time":90,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-05T12:18:37.706Z","updated_at":"2026-02-23T08:02:31.084Z","avatar_url":"https://github.com/Excoriate.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Terraform PreCommit Hooks\nThese Hooks work out with pre-commit framework 🚀 — These hooks found inspiration in some other nice projects available in the community, however, I've added my own additions, like adding a hook to cleaning up the `.terraform` (metadata) folder which is usually generated whenever we run a local `terraform` command, or the addition of the `terraform plan` hook as well.\n\n## Hooks\n\nThese hooks works with  [pre-commit](https://pre-commit.com/) and act onto (`*.tf` and `*.tfvars`) depending on the `file` configuration placed in the main `.pre-commit.hooks.yaml` file. Whether in the future I (or anyone who wanna contribute here) found that's needed a new hook, please, feel free to raise a `feature request or, even better! just push your PR!\n\n| Hook                                              | Description                                                                                                                |\n| ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------- |\n| `terraform-validate`                             | Validates all Terraform configuration files.                                                                               |\n| `terraform-validate-full`                             | Validates all Terraform configuration files (with full backend configuration)                                                                              |\n| `terraform-fmt`                                  | Format (check and fix) Terraform configuration following the canonical format.                                                          |\n| `terraform-docs`                                 | Generate and keep up to date the documentation of terraform components. Re-write the `readme.md` file dynamically                                                      |\n| `terraform-lint`                               | Use [TFLint](https://github.com/terraform-linters/tflint) to prevent bugs!                           |\n| `terraform-clean`                                 | Get rid of the `.terraform` folder on local executions, after you've done all your local terraform commands. |\n| `terraform-sec`                            | Validates all Terraform configuration from the security point of view. It uses [TFSec](https://github.com/liamg/tfsec)                       |\n| `terraform-plan`                                | Execute terraform plan command onto specific terraform modules (supports extra vars) |\n\n## Configuration\n### 1. Install dependencies\n\n* [`pre-commit`](https://pre-commit.com/#install)\n* [`terraform-docs`](https://github.com/terraform-docs/terraform-docs) required for `terraform_docs` hooks.\n* [`TFLint`](https://github.com/terraform-linters/tflint)\n* [`TFSec`](https://github.com/liamg/tfsec)\n\n##### MacOS\n\n```bash\nbrew install pre-commit gawk terraform-docs tflint tfsec coreutils\n```\nOr run this script\n```bash\n npm run lib:install\n```\n\n\n### 2. Hook consumer configuration\n\nAfter pre-commit hook has been installed you can run it manually on all files in the repository\n\n```bash\npre-commit run -a\n```\n\nAt the repository level, add the following file called `.pre-commit-config.yaml` with the following contents (This is just an example. You can add whatever available hook you might need. In addition, depending in your folder structure, you can use the same hook that acts in different `submodules` within your `terraform` project ;)):\n\n```yaml\nrepos:\n    -   repo: https://github.com/Excoriate/terraform-precommit-hooks.git\n        rev: v0.0.1\n        hooks:\n            -  id: terraform-clean\n              files: ^module/\n              args:\n                - \"--dir=module\"\n            -  id: terraform-sec\n              files: ^module/\n              args:\n                - \"--dir=module\"\n\n```\n\n### 3. Use notes\nEvery time you commit a code change (`.tf` file), the hooks in the `.pre-commit-config.yaml` will be executed.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexcoriate%2Fterraform-precommit-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexcoriate%2Fterraform-precommit-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexcoriate%2Fterraform-precommit-hooks/lists"}