Six Pre-commit Hook Tips for Terraform and Python Repositories
A common frustration in pull requests is reviewers repeatedly flagging formatting and lint issues that could be caught earlier. Pre-commit hooks move these checks onto the developer's machine before a commit is created, which is especially useful for repos combining Terraform with Python code such as Lambda handlers. The guidance recommends pinning each hook to a specific tag or commit SHA rather than a branch name, and updating deliberately with autoupdate so local machines and CI stay aligned. It suggests starting with Terraform fmt, tflint, and terraform-docs, then using Ruff to handle Python linting and formatting in one tool. The article also warns that hook IDs can change between releases and that hooks should not run terraform plan, since that requires credentials and network access best kept in CI.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in