最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How do I use a GitHub PAT in a GitLab CI job to authenticate when using TFLint - Stack Overflow

programmeradmin4浏览0评论

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.

Share Improve this question asked 14 hours ago chrischris 211 silver badge2 bronze badges New contributor chris is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
Add a comment  | 

1 Answer 1

Reset to default 2

I 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}

发布评论

评论列表(0)

  1. 暂无评论