We're getting rate limited by Github, when running tflint --init
which is trying to pull (for example) the AWS plugin.
Example Output:
Installing "aws" plugin... Failed to install a plugin; Failed to fetch GitHub releases: GET .36.0: 403 API rate limit exceeded
I understand that authenticating by using a GitHub access token increases the rate at which you can query the API. I have generated a new token to use for this, but I'm stuck as to how to use it.
For example, given this GitLab-CI job, where do I add in the GitHub token?
lint:
stage: Code Quality
needs: []
image:
name: ####
script:
- tflint --init -c .tflint.hcl
I've had a look through the GitLab CI syntax reference for anything related to tokens but nothing relates to this use case. I've also tried passing the token - for example tflint --init -c .tflint.hcl ${GITHUB_TOKEN}
but have had no luck so far.
We're getting rate limited by Github, when running tflint --init
which is trying to pull (for example) the AWS plugin.
Example Output:
Installing "aws" plugin... Failed to install a plugin; Failed to fetch GitHub releases: GET https://api.github/repos/terraform-linters/tflint-ruleset-aws/releases/tags/v0.36.0: 403 API rate limit exceeded
I understand that authenticating by using a GitHub access token increases the rate at which you can query the API. I have generated a new token to use for this, but I'm stuck as to how to use it.
For example, given this GitLab-CI job, where do I add in the GitHub token?
lint:
stage: Code Quality
needs: []
image:
name: ####
script:
- tflint --init -c .tflint.hcl
I've had a look through the GitLab CI syntax reference for anything related to tokens but nothing relates to this use case. I've also tried passing the token - for example tflint --init -c .tflint.hcl ${GITHUB_TOKEN}
but have had no luck so far.
1 Answer
Reset to default 2I stumbled across the answer to this question on a hunch so posting the solution in case anyone else has the same issue.
In GitHub, TFLint relies on the GITHUB_TOKEN
automatically generated by the workflow to authenticate with the GitHub API.
So in an attempt to replicate this, I created a new GitHub PAT, and added it to my GitLab pipeline as a variable named GITHUB_TOKEN
. Then in the pipeline script, before I call TFLint I added the following line:
GITHUB_TOKEN=${GITHUB_TOKEN}