Вход на сайт

Просмотр новости

Найдите то, что Вас интересует

Validating packer templates with GitHub Actions

Дата публикации: 22-03-2024 13:30:21

I setup a GitHub Action for my packer-aws-windows-openssh project last month and it was working pretty well until a recent job failed with this:Run packer init ./aws-windows-ssh.pkr.hcl
Failed getting the "github.com/hashicorp/amazon" plugin:
1 error occurred:
* Plugin host

Основное содержимое страницы с новостью.

I setup a GitHub Action for my packer-aws-windows-openssh project last month and it was working pretty well until a recent job failed with this:

Run packer init ./aws-windows-ssh.pkr.hcl
Failed getting the "github.com/hashicorp/amazon" plugin:
1 error occurred:
	* Plugin host rate limited the plugin getter. Try again in 43m44.793174231s.
HINT: Set the PACKER_GITHUB_API_TOKEN env var with a token to get more requests.
GET https://api.github.com/repos/hashicorp/packer-plugin-amazon/git/matching-refs/tags: 403 API rate limit exceeded for 172.183.131.31. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.) [rate reset in 43m45s]

This happened during the packer init part of my GitHub action. The packer init command queries GitHub's public API, which rate limits requests per IP address. With GitHub actions, it's quite easy to hit this limit. The packer doc mentions setting PACKER_GITHUB_API_TOKEN but it doesn't get into specifics. Outside of GitHub actions, like running this from your local laptop, you'd probably not hit this issue at all

Fortunately, setting this up in an GitHub Action is fairly easy and you don't need to manually create token, you just set PACKER_GITHUB_API_TOKEN to ${{ secrets.GITHUB_TOKEN }} :

env:
  PACKER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

GitHub automatically creates a token for you, called GITHUB_TOKEN, which you can use in your workflow. You would put the above two lines at the top of your action, right before jobs:. Here's a full example of my GitHub action so you can see it in context:

name: Validate packer templates

on:
  pull_request:

env:
  PACKER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
  packer-validate:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup `packer`
        uses: hashicorp/setup-packer@v3
        id: setup

      - name: Run `packer init`
        id: init
        run: "packer init ./aws-windows-ssh.pkr.hcl"

      - name: Run `packer validate`
        id: validate
        run: "packer validate ./aws-windows-ssh.pkr.hcl"

Once PACKER_GITHUB_API_TOKEN is set in your action, you shouldn't see the rate limit error anymore.

Схожие новости

#Наименование новостиТональностьИнформативностьДата публикации
1Running PSScriptAnalyzer in GitHub Actions010.4101-03-2024
2Building Windows AMIs with Packer06.1710-06-2026
3Playwright tests show up as failed on Github while running then turn to success when done04.7623-05-2026
4Actions Larger Runner Jobs for some customers may be slow to start010.9414-09-2026
5Incident with Actions0805-10-2026
6[Retroactive] Actions workflow run failures after deployment gate approvals01001-10-2026
7Compromised GitHub Actions Came Back Online and Resumed Executing Mini Shai-Hulud Malware013.8225-09-2026
8Copy Fix Prompt, diagnose and fix failures with any AI coding agent06.4812-08-2026
9GitHub Outage015.3128-08-2026
10Native GitHub Actions YAML Workflow Support — Preview06.8122-09-2026

Классификация: . Схожих патентов: 0. Схожих новостей: 10. Тональность: 0. Информативность: 14.64. Источник: horrell.ca.