AWS Lambda to Amazon DynamoDB

AWS Lambda → Amazon DynamoDB

Persist an item to a DynamoDB table from a Lambda function

This project contains a sample AWS Cloud Development Kit (AWS CDK) template for deploying a Lambda function that makes puts to a DynamoDB table.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/lambda-dynamodb-cdk

Deploy

npm inpx cdk deploy


Testing

Run the following Lambda CLI invoke command to invoke the function. Note, you must edit the {LambdFunctionArn} placeholder with the ARN of the deployed Lambda function. This is provided in the stack outputs.
aws lambda invoke --function-name {LambdFunctionArn} --invocation-type Event --payload '{ "Metadata": "Hello" }' response.json --cli-binary-format raw-in-base64-out

Cleanup

1. Delete the stack: npx cdk destroy.
2. Confirm the stack has been deleted: aws cloudformation list-stacks --query "StackSummaries[?contains(StackName,'STACK_NAME')].StackStatus".
3. You see a message confirming DELETE_COMPLETE.

Created by:

Glenn Chia Jin Wee

Glenn Chia Jin Wee

Glenn is an Associate Cloud Architect at AWS based in Singapore

Follow on LinkedIn