Search code examples
amazon-web-servicesbototox

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


Solution

  • 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_*