configure-aws-credentials icon indicating copy to clipboard operation
configure-aws-credentials copied to clipboard

Unable to use in reusable workflow: `Error: The security token included in the request is invalid.`

Open choffa opened this issue 3 years ago • 4 comments

I have been trying to use this action in a reusable workflow. Whenever I try to I get an Error: The security token included in the request is invalid. My motivation for using the action in this way, is to be able to do the same workflow on different accounts, depending in the circumstances, such as deploying dev on push, and prod manually.

Reproduction steps:

My called (reusable) workflow looks as follows:

name: Deploy

on:
  workflow_call:
    inputs:
      aws-region:
        required: true
        type: string
    secrets:
      AWS_ACCESS_KEY_ID:
        required: true
      AWS_SECRET_ACCESS_KEY:
        required: true

jobs:
  test:
    name: Test-secrets
    runs-on: ubuntu-latest
    steps:
    - 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: ${{ inputs.aws-region }}

And the caller workflow looks like:

name: Continous Delivery

on: push

jobs:
  deploy-dev:
    name: Deploy Dev
    uses: ./.github/workflows/deploy.yml
    with:
      aws-region: eu-west-1
    secrets:
      AWS_ACCESS_KEY_ID: $${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
      AWS_SECRET_ACCESS_KEY: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}

Expected behaviour

I expect the action to work as normal, like it does when used directly, ie.

name: Continous Delivery

on: push

jobs:

  test-directly:
    name: Test Directly on push
    runs-on: ubuntu-latest
    steps:
    - uses: aws-actions/configure-aws-credentials@v1
      with:
        aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
        aws-secret-access-key:  ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
        aws-region: eu-west-1

Using the action this way works just fine. That also confirms that it is not the secrets that are the issue...

Let me know if you need anything else! :)

choffa avatar Feb 13 '22 12:02 choffa

@choffa Did you find a workaround? I am also facing this issue.

jim-hill-r avatar Jul 20 '22 16:07 jim-hill-r

@choffa Please let me know if you find a workaround. I am having the same issue

drey0143143 avatar Jul 24 '22 19:07 drey0143143

@jim-hill-r @drey0143143 No, I was not able to find a good workaround for this issue. We decided to accept the duplication for now.

choffa avatar Aug 01 '22 08:08 choffa

I was having a problem with Azure credentials which seem similar to the one above. I was able to solve it following the steps at the link below: https://colinsalmcorner.com/consuming-environment-secrets-in-reusable-workflows/

In short, it suggests to have the credentials in an environments and pass the environment as a parameter by the caller workflow.

emmanuel-c-santos avatar Sep 28 '22 13:09 emmanuel-c-santos

I'm facing the same issue

cleber-rocha avatar Aug 24 '23 14:08 cleber-rocha

I suspect this would be due to existing credentials within the runner, or lack thereof. I'm not super experienced with reusable workflows, but I'd like it if the people running into this could check if their environment variables are populated at the time the configure-aws-credentials step runs.

If you upgrade to v3, there is now the role-chaining prop which helps avoid errors in some cases where the action is invoked multiple times. Alternately, there's the unset-current-credentials prop which clears AWS-related environment variables at the start of the step.

If there's no issue with inputs, and there's no unexpected environment variables in the runner, then I'm not sure why a composite action would be failing and would need to look more into it.

peterwoodworth avatar Aug 24 '23 22:08 peterwoodworth

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

github-actions[bot] avatar Aug 30 '23 00:08 github-actions[bot]

The project where I faced this issue has since been cancelled, so I now have no way to test @peterwoodworth 's suggestion.

choffa avatar Aug 30 '23 11:08 choffa

In that case, please feel free to open a new issue if anyone encounters any problems on v4. thanks!

peterwoodworth avatar Sep 14 '23 17:09 peterwoodworth

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one.

github-actions[bot] avatar Sep 14 '23 17:09 github-actions[bot]