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

Could not load credentials from any providers on GitHub Actions #76

Open
taschetto opened this issue Dec 8, 2021 · 2 comments
Open

Comments

@taschetto
Copy link

I'm using jest-dynalite to test my DynamoDB operations. This is the code I'm using to initialize the client.

const { DynamoDB } = require('@aws-sdk/client-dynamodb')
const { DynamoDBDocument } = require('@aws-sdk/lib-dynamodb')

const config = {
  region: process.env.AWS_REGION,
  ...(process.env.MOCK_DYNAMODB_ENDPOINT && {
    endpoint: process.env.MOCK_DYNAMODB_ENDPOINT,
    sslEnabled: false,
    region: 'local',
  }),
}

const client = new DynamoDB(config)
const document = DynamoDBDocument.from(client)

module.exports = {
  client,
  document,
}

The tests are passing in my local environment and my code is working as expected in production (AWS lambda). Sadly, the tests are failing on CI (GitHub Actions):

FAIL src/utils.test.js
  ● getQueryParamsFromEvent › should mount parameters from a well formed event

    CredentialsProviderError: Could not load credentials from any providers

      at providers (node_modules/@aws-sdk/credential-provider-node/dist-cjs/index.js:25:19)
      at node_modules/@aws-sdk/property-provider/dist-cjs/chain.js:11:28
      at coalesceProvider (node_modules/@aws-sdk/property-provider/dist-cjs/memoize.js:13:24)
      at SignatureV4.credentialProvider (node_modules/@aws-sdk/property-provider/dist-cjs/memoize.js:32:24)
      at SignatureV4.signRequest (node_modules/@aws-sdk/signature-v4/dist-cjs/SignatureV4.js:84:29)
      at node_modules/@aws-sdk/middleware-signing/dist-cjs/middleware.js:13:18
      at StandardRetryStrategy.retry (node_modules/@aws-sdk/middleware-retry/dist-cjs/StandardRetryStrategy.js:51:46)
      at node_modules/@aws-sdk/middleware-logger/dist-cjs/loggerMiddleware.js:6:22
          at async Promise.all (index 0)

My workflow is correctly setting up the environment variables:

  my-project:
    runs-on: ubuntu-20.04
    steps:
      - name: Configure AWS Credentials
        uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: ${{ secrets.CI_AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.CI_AWS_SECRET_ACCESS_KEY }}
          aws-region: ${{env.AWS_REGION}}
          role-to-assume: ci-github
          role-external-id: ci-github
          role-duration-seconds: 3600
          role-session-name: ${{ github.job }}-${{ github.run_id }}-${{ github.run_number}}
      - name: Checkout Code
        uses: actions/checkout@v2
      - name: Install Dependencies
        run: yarn install
      - name: Run Unit Tests
        run: yarn test

Are there any additional steps for this to work? Thanks for your help.

@freshollie
Copy link
Owner

Don't understand this one. Did you manage to get any further?

@James1218
Copy link

@taschetto HI, I'm having the same error CredentialsProviderError: Could not load credentials from any providers. Did you figure it out? Thanks.

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