Now that we have our DynamoDB Stream enabled and our Lambda function deployed it is time to tie them together. This is called adding an event source to Lambda function. The event source can be configured in the AWS Lambda Console or the AWS Toolkit for Visual Studio.
After the Lambda function was deployed the Lambda function view was displayed from the AWS Explorer. From this view you can create the event source mapping by:
- Select the Event Sources tab
- Push the Add button
- Select Amazon DynamoDB Stream for the Source Type
- Make sure the Stream we enabled previously is selected for the DynamoDB Stream
- Set the Starting Position to LATEST
- Push OK
Note: Batch Size and Starting Position can be left at the default values. Starting Position has 2 possible values. TRIM_HORIZON basically means start reading from the stream at the earliest point still available in the stream. This is at most 24 hours in the past. LATEST means start reading items starting from the point the mapping event source was made.
Instructions for configuring with the AWS Lambda Console:
- Log on to the AWS Lambda Lambda Console
- Choose the region you deployed to
- Select the deployed function
- In the Add triggers panel select DynamoDB
- In the Configure triggers below select the DynamoDB table and push Add
- Push the Save button for the Lambda function
The code below uses the AWS SDK for .NET to add the event source. You must set the name of the function to the name that you deployed with earlier to the functionName variable.
- Getting Started
- What is a serverless application?
- Common AWS Serverless Services
- What are we going to build in this tutorial?
- TODO List AWS Services Used
- Using DynamoDB to store TODO Lists
- Handling service events with Lambda
- Getting ASP.NET Core ready for Serverless
- Deploying ASP.NET Core as a Serverless Application
- Tear Down
- Final Wrap Up
Continue on to next page: Setting up Amazon Simple Email Service (SES)
