AWS Nodejs v20 Lambda: Unable to load credentials

0

Initializing the dynamo client as follows-

const dynamoDBClient = new DynamoDBClient({ region: 'us-west-1', credentials: defaultProvider() });

Error:

2024-01-18T17:47:48.879Z	9ec651f1-4703-49f2-b03a-94c118e3e502	INFO	CredentialsProviderError: Could not load credentials from any providers
    at /var/task/node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/credential-provider-node/dist-cjs/defaultProvider.js:13:11
    at /var/task/node_modules/@smithy/property-provider/dist-cjs/chain.js:12:39
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async coalesceProvider (/var/task/node_modules/@smithy/property-provider/dist-cjs/memoize.js:14:24)
    at async /var/task/node_modules/@smithy/property-provider/dist-cjs/memoize.js:33:24
    at async /var/task/node_modules/@smithy/core/dist-cjs/middleware-http-auth-scheme/httpAuthSchemeMiddleware.js:35:23
    at async /var/task/node_modules/@aws-sdk/middleware-logger/dist-cjs/loggerMiddleware.js:7:26
    at async findLoggedInUser (/var/task/storage/database.js:172:18)
    at async clerkAuth (/var/task/middleware/authentication.js:58:30)
    at async handleRequest (/var/task/handlers/dashboard.js:100:34) {
  tryNextLink: false
}

Have spent hours on this. Also created a role for the lambda and gave it tons of permissions.

sj
질문됨 4달 전241회 조회
2개 답변
1

Try without specifying the credential creation in the initializer

const dynamoDBClient = new DynamoDBClient({ region: 'us-west-1'});

If that fails, share your IAM policy as its hard to decipher what a ton of permissions are. Follow this blog for guidance: https://aws.amazon.com/blogs/security/how-to-create-an-aws-iam-policy-to-grant-aws-lambda-access-to-an-amazon-dynamodb-table/

profile pictureAWS
전문가
답변함 4달 전
0

Hi!

It seems like your Lambda function is struggling to load the necessary credentials for DynamoDB. Given that you've already assigned a role with extensive permissions, the issue might be in the IAM role configuration or the default credentials provider. Sometimes, the smallest oversight in role permissions or trust relationships can lead to such errors. Also, ensure that the AWS SDK version you're using aligns with your Node.js setup. If these aspects all check out, it might be worth enabling more detailed logging for deeper insights, or even reaching out to AWS support for that extra bit of help. Hang in there, these issues can be tricky but are often solvable with a bit of persistence and the right approach.

I'm here to help with any further questions or guidance you might need.

profile picture
답변함 4달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠