Oliver Robie
Oliver Robie

Reputation: 976

How to solve botocore.exceptions.NoCredentialsError: Unable to locate credentials

I have a GitHub action which is running a tox.ini file. One of the steps of the action is to connect to aws and the last step is to run tox

- name: Configure AWS credentials
      uses: aws-actions/configure-aws-credentials@v1
      with:
        aws-access-key-id: ${{ secrets.key }}
        aws-secret-access-key: ${{ secrets.secret_key }}
        aws-region: ${{ secretes.region }}
- name: Run tox
      run: tox

And for some reason my action fails with the following error botocore.exceptions.NoCredentialsError: Unable to locate credentials
I'm not sure why this is happening especially since the aws configuration step is passing in the action

Upvotes: 5

Views: 5855

Answers (1)

jordanm
jordanm

Reputation: 34914

The reason you still get this error after setting credentials is because the aws-actions/configure-aws-credentials sets environment variables and tox, by default, does not pass along env vars. You can tell tox to pass the variables in your tox.ini file. Something like this:

[testenv]
passenv = AWS_*

Upvotes: 5

Related Questions