Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make this action compatible with aws-actions/configure-aws-credentials #20

Closed
dbuades opened this issue Oct 19, 2020 · 4 comments · Fixed by #21
Closed

Make this action compatible with aws-actions/configure-aws-credentials #20

dbuades opened this issue Oct 19, 2020 · 4 comments · Fixed by #21

Comments

@dbuades
Copy link

dbuades commented Oct 19, 2020

Behaviour

The official AWS action for setting up credentials works very well for assuming roles. Ideally, this action should be compatible with it. We have been using https://github.com/aws-actions/amazon-ecr-login for logging in, but it is not compatible with your new https://github.com/docker/build-push-action.

Something like this would be very useful:

      - name: Configure AWS Credentials
        uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: ${{ secrets.ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.SECRET_ACCESS_KEY }}
          aws-region: ${{ secrets.DEFAULT_REGION }}
          role-to-assume: ${{ secrets.ROLE_ARN }}
          role-duration-seconds: 1200
          role-session-name: GithubActions

      - name: Login to Amazon ECR
        uses: docker/login-action@v1
        with:
          registry: ${{ secrets.ECR_REGISTRY }}

     - name: Build and push
        id: docker_build
        uses: docker/build-push-action@v2
        with:
          ...

What do you think? Is there a known workaround to accomplish this? Thanks in advance!

@crazy-max
Copy link
Member

@dbuades This action already handles AWS Elastic Container Registry (ECR):

      - name: Login to Amazon ECR
        uses: docker/login-action@v1
        with:
          registry: ${{ secrets.ECR_REGISTRY }}
          username: ${{ secrets.ACCESS_KEY_ID }}
          password: ${{ secrets.SECRET_ACCESS_KEY }}

     - name: Build and push
        id: docker_build
        uses: docker/build-push-action@v2
        with:
          ...

If role-* are required on your side, then yes maybe we should be compatible with aws-actions/configure-aws-credentials.

@dbuades
Copy link
Author

dbuades commented Oct 19, 2020

@dbuades This action already handles AWS Elastic Container Registry (ECR):

      - name: Login to Amazon ECR
        uses: docker/login-action@v1
        with:
          registry: ${{ secrets.ECR_REGISTRY }}
          username: ${{ secrets.ACCESS_KEY_ID }}
          password: ${{ secrets.SECRET_ACCESS_KEY }}

     - name: Build and push
        id: docker_build
        uses: docker/build-push-action@v2
        with:
          ...

If role-* are required on your side, then yes maybe we should be compatible with aws-actions/configure-aws-credentials.

Yes, that's what I meant, we need roles on our side and unfortunately this action doesn't support them.
I guess making this action compatible with aws-actions/configure-aws-credentials is the easiest way to go, so that's why I suggested it.
Thanks and sorry if I didn't explain myself clearly!

@crazy-max
Copy link
Member

crazy-max commented Oct 19, 2020

@dbuades

Yes, that's what I meant, we need roles on our side and unfortunately this action doesn't support them.

My bad I read it wrong. Something like this should work in the meantime:

      - name: Configure AWS Credentials
        uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: ${{ secrets.ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.SECRET_ACCESS_KEY }}
          aws-region: ${{ secrets.DEFAULT_REGION }}
          role-to-assume: ${{ secrets.ROLE_ARN }}
          role-duration-seconds: 1200
          role-session-name: GithubActions

      - name: Login to Amazon ECR
        uses: docker/login-action@v1
        with:
          registry: ${{ secrets.ECR_REGISTRY }}
          username: ${{ secrets.ACCESS_KEY_ID }}
          password: ${{ secrets.SECRET_ACCESS_KEY }}

     - name: Build and push
        id: docker_build
        uses: docker/build-push-action@v2
        with:
          ...

Env vars exported by aws-actions/configure-aws-credentials will be used through the ecr get-login cmd

@dbuades
Copy link
Author

dbuades commented Oct 20, 2020

That was really really quick, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants