7
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

GitHub ActionsでECRのプライベートイメージを使う。2021-04-06

Last updated at Posted at 2021-04-06

概要

  • ECRからpullするときに docker login する必要がある
  • aws ecr get-login-password で取得したパスワードには有効期限がある

で一手間必要です。

参考:

設定例

以下の設定で動いた雰囲気。

name: Test

on:
  - push
  - pull_request

jobs:
  login:
    runs-on: ubuntu-latest
    outputs:
      password: ${{ steps.get_password.outputs.password }}
    steps:
      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: ap-northeast-1
      - id: get_password
        run: echo "::set-output name=password::$(aws ecr get-login-password)"

  test:
    needs: login
    runs-on: ubuntu-latest
    container:
      image: xxx.dkr.ecr.ap-northeast-1.amazonaws.com/test:latest
      credentials:
        username: AWS
        password: ${{ needs.login.outputs.password }}
    steps:
      - run: node -v
      - run: npm -v

ポイント

  • job: loginで aws ecr get-login-password してパスワードを取得
  • job: testでそのパスワードを利用してECRのプライベートコンテナ利用

気になるポイント(懸念点)

パスワードがログに出力されてなかったから大丈夫だと思うけど aws ecr get-login-password してるところ

まとめ

ちょっと気になるポイントがありますが、GitHub ActionsでECRのプライベートイメージを使えました。

参考

7
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?