Introduction
DynamoDB is a fast, flexible database, and Lambda lets you run code without managing servers. Together, they help build apps that respond quickly to data changes.
DynamoDB is a fast, flexible database, and Lambda lets you run code without managing servers. Together, they help build apps that respond quickly to data changes.
No direct code syntax since this is a concept pairing, but typically:
- DynamoDB stores data.
- Lambda functions are triggered by DynamoDB events.1. DynamoDB table stores user info. 2. User updates info. 3. DynamoDB Streams detect change. 4. Lambda function runs to send a welcome email.
1. IoT device sends data to DynamoDB. 2. DynamoDB Streams trigger Lambda. 3. Lambda processes data and stores results elsewhere.
This example shows the setup: DynamoDB stores data, and Lambda reacts to changes automatically.
-- This is a conceptual example showing DynamoDB Stream triggering Lambda -- No direct SQL code. DynamoDB table setup (via AWS Console/CLI): -- Table: Users -- Partition Key: UserId (String) -- Attributes: Name (String), Email (String) -- Enable DynamoDB Streams (e.g., New image) -- When a new user is added (e.g., via PutItem), DynamoDB Streams triggers a Lambda function to send a welcome email.
DynamoDB Streams capture data changes in near real-time.
Lambda functions run only when triggered, saving resources.
This pairing is great for building scalable, event-driven apps without servers.
DynamoDB stores data quickly and scales easily.
Lambda runs code automatically when data changes.
Together, they enable serverless, event-driven applications.
exports.handler = async (event) => {
for (const record of event.Records) {
if (record.eventName === 'INSERT') {
console.log('New item:', record.dynamodb.NewImage);
}
}
};exports.handler = async (event) => {
console.log('Event received');
};
Options:Pass the test and this pattern moves unknown