AWS Lambda custom triggers


Can someone tell me how to get access to AWS credentials in an AWS Lambda function?

I’ve searched the internet thoroughly but still haven’t found anything that has helped me.

Im writing the function in Java. I think I should have access to the credentials with the context object in the HandleRequest method.

If it helps, I want to invoke a DynamoDB client and upload a record to the database.


I came into the same problem myself recently.
This certainly is a blind spot in AWS’s Lambda documentation for Java, in my opinion.

This snippet in Java should work for you, assuming you’re using the AWS SDK for Java Document API :

The main takeaway is to use the EnvironmentVariableCredentialsProvider to access the required credentials to access your other AWS resources within the AWS Lambda container. The Lambda containers are shipped with credentials as environment variables, and this is sufficient in retrieving them.

Note: This creates a DynamoDB instance that only sees resources in the default region. To create one for a specific region, use this (assuming you want to access DynamoDB’s in the ap-northeast-1 region):

Leave a Reply