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

Supplying AWS creds but still getting missing username warning #153

Open
bagedevimo opened this issue Dec 18, 2023 · 9 comments
Open

Supplying AWS creds but still getting missing username warning #153

bagedevimo opened this issue Dec 18, 2023 · 9 comments

Comments

@bagedevimo
Copy link

When running this action after the aws-actions/configure-aws-credentials action, variables are set but the docker-build-with-cache-action doesn't seem to be detecting them? Possibly because i'm using OIDC login so i'm not explicitly setting those variables?

      uses: aws-actions/configure-aws-credentials@v4
      with:
        role-to-assume: ${{ secrets.ECR_IAM_ROLE_TO_ASSUME }}
        aws-region: ap-southeast-2

Output:

Run whoan/docker-build-with-cache-action@v8.0.2
  with:
    registry: 224854405218.dkr.ecr.ap-southeast-2.amazonaws.com/delivereasy/core
    image_name: some-build
    image_tag: d75c5b8136235f61cc692f96c1e5b7914566a3c5
    services_regex: .+
    context: .
    dockerfile: Dockerfile
    push_image_and_stages: true
    push_git_tag: false
    pull_image_and_stages: true
  env:
    AWS_DEFAULT_REGION: ap-southeast-2
    AWS_REGION: ap-southeast-2
    AWS_ACCESS_KEY_ID: ***
    AWS_SECRET_ACCESS_KEY: ***
    AWS_SESSION_TOKEN: ***
@ricky-sb
Copy link

I'm also experiencing this - using OIDC. Did you ever find a fix for this?

@whoan
Copy link
Owner

whoan commented Jan 13, 2024

I'll have to take a look as I have not tested this scenario.
First of all, have you set id-token: write permission as mentioned in the OIDC docs?

NVM. Again, I'll have to take a look. No much time lately though.


Update:

Can someone please test this?

- uses: aws-actions/configure-aws-credentials@v4
  id: creds
  ...

- uses: whoan/docker-build-with-cache-action@v8
  with:
    username: "${{ steps.creds.outputs.aws-access-key-id }}"
    password: "${{ steps.creds.outputs.aws-secret-access-key }}"
    session: "${{ steps.creds.outputs.aws-session-token }}"
    ...

I've taken it from here https://github.com/aws-actions/configure-aws-credentials#retrieving-credentials-from-step-output-assumerole-with-temporary-credentials

@bagedevimo
Copy link
Author

bagedevimo commented Jan 16, 2024

Unfortunately that didn't seem to work:

Run aws-actions/configure-aws-credentials@v4
Assuming role with OIDC
Authenticated as assumedRoleId
image

my yml has:

    - name: Configure AWS creds
      uses: aws-actions/configure-aws-credentials@v4
      id: creds
      with:
        role-to-assume: ${{ secrets.ECR_IAM_ROLE_TO_ASSUME }}
        aws-region: ap-southeast-2
    - name: "Build the image and cache"
      uses: whoan/docker-build-with-cache-action@v8
      with:
        username: "${{ steps.creds.outputs.aws-access-key-id }}"
        password: "${{ steps.creds.outputs.aws-secret-key-id }}"
        session: "${{ steps.creds.outputs.aws-session-token }}"
        registry: <a-registry-ref>
        image_name: "some-build"
        image_tag: "${{ github.sha }}"

@bagedevimo
Copy link
Author

ah, just spotted the typo there - fixing and trying again.

@bagedevimo
Copy link
Author

bagedevimo commented Jan 16, 2024

with those typos fixed, it still fails, here's some debug logs:

image image

partially cropped to preserve IDs that aren't really sensitive but i'm paranoid

@bagedevimo
Copy link
Author

I've just noticed this, have I just forgotten some key somewhere?

image

@whoan
Copy link
Owner

whoan commented Jan 17, 2024

@bagedevimo According to configure-aws-credentials docs, when you use OIDC, you need to set an audience as an input: https://github.com/aws-actions/configure-aws-credentials#OIDC

@bagedevimo
Copy link
Author

that same link says there is a default audience (which should be correct for our partition) and it does seem that the login is working fine on the AWS task - just not picking up the credentials in the build and push step.

@whoan
Copy link
Owner

whoan commented Jan 18, 2024

@bagedevimo Will have to write a test to play with it. Give me some time for that.
Feel free to keep on trying and suggest a solution also. I am pretty sure it should be possible to solve through configs.

Thanks for bringing this up.

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

No branches or pull requests

3 participants