Summary
The terraform_tflint pre-commit hook runs tflint --init which pulls plugin tarballs (e.g. tflint-ruleset-azurerm v0.27.0) from api.github.com/repos/terraform-linters/... unauthenticated, hitting the 60-requests-per-hour anonymous rate limit per runner IP. When this trips, the pre-commit job fails with:
Failed to install a plugin; Failed to fetch GitHub releases:
GET https://api.github.com/repos/terraform-linters/tflint-ruleset-azurerm/releases/tags/v0.27.0:
403 API rate limit exceeded for 52.186.174.153.
[rate reset in 17m33s]
Observed on run 26160016057 for PR #560; a manual rerun later passed (rate window reset). Will recur arbitrarily as more PRs land same hour on the same NAT IP range.
Suggested fix
Pass GITHUB_TOKEN to tflint --init so it authenticates against the GitHub API (5000/hr limit, per-token). tflint reads it from the GITHUB_TOKEN env var natively. Easiest insertion point: the pre-commit job in .github/workflows/pre-commit.yml already has secrets.GITHUB_TOKEN available — add an env: block on the Run pre-commit step:
- name: Run pre-commit
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: pre-commit run --all-files
The hook itself doesn't need editing; tflint picks up the env var.
Acceptance criteria
Cross-references
Summary
The
terraform_tflintpre-commit hook runstflint --initwhich pulls plugin tarballs (e.g.tflint-ruleset-azurerm v0.27.0) fromapi.github.com/repos/terraform-linters/...unauthenticated, hitting the 60-requests-per-hour anonymous rate limit per runner IP. When this trips, the pre-commit job fails with:Observed on run 26160016057 for PR #560; a manual rerun later passed (rate window reset). Will recur arbitrarily as more PRs land same hour on the same NAT IP range.
Suggested fix
Pass
GITHUB_TOKENtotflint --initso it authenticates against the GitHub API (5000/hr limit, per-token). tflint reads it from theGITHUB_TOKENenv var natively. Easiest insertion point: the pre-commit job in.github/workflows/pre-commit.ymlalready hassecrets.GITHUB_TOKENavailable — add anenv:block on theRun pre-commitstep:The hook itself doesn't need editing; tflint picks up the env var.
Acceptance criteria
Run pre-commitstep in.github/workflows/pre-commit.yml(or equivalent) exposesGITHUB_TOKENto the environment.pre-commitruns in the same hour (across separate PRs) all complete without atflintrate-limit failure.Cross-references
.pre-commit-config.yamlterraform_tflintentry.github/workflows/pre-commit.yml