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
demandé il y a 4 mois241 vues
2 réponses
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
EXPERT
répondu il y a 4 mois
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
répondu il y a 4 mois

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions