AWS Lambda Secrets Manager top-level await + SDKv3

Lambda using SDKv3 → Secrets Manager

Lambda function retrieving a secret from Secrets Manager using top-level await using AWS SDK for JavaScript v3.

This pattern stores a secret in Secrets Manager. A Node.js Lambda function uses top-level await and the AWS SDK for Javascript v3 to read the secret in the init phase, outside the handler.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Launch Stack

Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/lambda-secretsmanager-node-sdkv3-sam

Deploy

sam buildsam deploy --guided


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

1. Delete the stack: sam delete --stack-name STACK_NAME.
2. Confirm the stack has been deleted: aws cloudformation list-stacks --query "StackSummaries[?contains(StackName,'STACK_NAME')].StackStatus"

Created by:

Julian Wood

Julian Wood

I help developers and builders learn about and love how serverless technologies can transform the way they build and run applications.

Follow on LinkedIn