{"id":23658802,"url":"https://github.com/equisoft-devops/equisoft-pre-commit","last_synced_at":"2025-10-29T16:16:40.978Z","repository":{"id":239935551,"uuid":"704602150","full_name":"equisoft-devops/equisoft-pre-commit","owner":"equisoft-devops","description":"Run tfsort with pre-commit","archived":false,"fork":false,"pushed_at":"2025-03-18T13:57:06.000Z","size":12,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-18T14:43:52.512Z","etag":null,"topics":["pre-commit","pre-commit-hook","pre-commit-hooks","terraform","tfsort"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/equisoft-devops.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-13T16:02:20.000Z","updated_at":"2025-01-21T17:30:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"76450861-6182-4345-9caf-62d0c45834c6","html_url":"https://github.com/equisoft-devops/equisoft-pre-commit","commit_stats":null,"previous_names":["equisoft-devops/equisoft-pre-commit"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/equisoft-devops%2Fequisoft-pre-commit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/equisoft-devops%2Fequisoft-pre-commit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/equisoft-devops%2Fequisoft-pre-commit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/equisoft-devops%2Fequisoft-pre-commit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/equisoft-devops","download_url":"https://codeload.github.com/equisoft-devops/equisoft-pre-commit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248255701,"owners_count":21073368,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["pre-commit","pre-commit-hook","pre-commit-hooks","terraform","tfsort"],"created_at":"2024-12-29T00:51:30.868Z","updated_at":"2025-10-29T16:16:40.966Z","avatar_url":"https://github.com/equisoft-devops.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pre-commit-tfsort\n\nA collection of pre-commit hooks for Terraform/OpenTofu projects, featuring automated sorting and security validation.\n\n\n## 🔧 tfsort Integration\n\n### What is tfsort?\n\n[tfsort](https://github.com/AlexNabokikh/tfsort) is a CLI tool that sorts Terraform/Opentofu configuration files to ensure consistent ordering of variables, outputs, and other blocks.\n\n### Prerequisites\n\n- [pre-commit](https://pre-commit.com/) installed\n- [tfsort](https://github.com/AlexNabokikh/tfsort) installed\n\n### Installing tfsort\n\n```bash\n# Using Go\ngo install github.com/AlexNabokikh/tfsort@latest\n\n# Using Homebrew (macOS/Linux)\nbrew install tfsort\n\n# Using npm\nnpm install -g tfsort\n```\n\n### tfsort Hook Configuration\n\nAdd to your `.pre-commit-config.yaml`:\n\n```yaml\nrepos:\n  - repo: https://github.com/equisoft-devops/equisoft-pre-commit\n    rev: v2\n    hooks:\n      - id: tfsort\n```\n\n### What the tfsort hook does\n\n**Files matched**: `variables.tf`, `outputs.tf`, `versions.tf`\n\n**Functionality**:\n- Sorts variable declarations alphabetically\n- Sorts output declarations alphabetically\n- Sorts provider and terraform blocks in versions files\n- Maintains proper Terraform syntax and formatting\n\n**Example**:\n```hcl\n# Before\nvariable \"environment\" {\n  description = \"Environment name\"\n  type        = string\n}\n\nvariable \"app_name\" {\n  description = \"Application name\"\n  type        = string\n}\n\n# After (sorted alphabetically)\nvariable \"app_name\" {\n  description = \"Application name\"\n  type        = string\n}\n\nvariable \"environment\" {\n  description = \"Environment name\"\n  type        = string\n}\n```\n\n### tfsort Configuration Options\n\n```yaml\nrepos:\n  - repo: https://github.com/mcantin/pre-commit-tfsort\n    rev: v1.0.0\n    hooks:\n      - id: tfsort\n        files: ^(variables|outputs|versions|locals)\\.tf$  # Include locals.tf, par default only variables, outputs, and versions\n        exclude: ^modules/legacy/  # Skip legacy modules\n```\n\n## 🔐 SOPS + KMS Integration\n\n### What is SOPS?\n\n[SOPS](https://github.com/mozilla/sops) (Secrets OPerationS) is an editor for encrypted files that supports AWS KMS, GCP KMS, Azure Key Vault, and PGP.\n\n### SOPS Hook Configuration\n\nAdd to your `.pre-commit-config.yaml`:\n\n```yaml\nrepos:\n  - repo: https://github.com/mcantin/pre-commit-tfsort\n    rev: v2\n    hooks:\n      - id: kms-check\n```\n\n### What the KMS check hook does\n\n**Files matched**: Files ending with `/secrets.yaml`\n\n**Functionality**:\n- Validates that encrypted files contain a KMS role ARN\n- Ensures the KMS key matches the environment directory structure\n- Prevents accidentally using wrong KMS keys across environments\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fequisoft-devops%2Fequisoft-pre-commit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fequisoft-devops%2Fequisoft-pre-commit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fequisoft-devops%2Fequisoft-pre-commit/lists"}