Introduction
Event-driven architecture helps systems react quickly to changes by using events as signals. It makes applications more flexible and responsive.
No single syntax; involves using DynamoDB Streams and AWS Lambda functions. Example steps: 1. Enable DynamoDB Streams on your table. 2. Create a Lambda function to process stream events. 3. Configure the Lambda to trigger on stream events. This setup lets your app react to data changes automatically.
Enable DynamoDB Streams on a table: aws dynamodb update-table --table-name Orders --stream-specification StreamEnabled=true,StreamViewType=NEW_IMAGE
Sample Lambda function handler in Python: def lambda_handler(event, context): for record in event['Records']: print('Event ID:', record['eventID']) print('Event Name:', record['eventName']) print('New Image:', record['dynamodb']['NewImage'])
1. Enable stream on 'Products' table: aws dynamodb update-table --table-name Products --stream-specification StreamEnabled=true,StreamViewType=NEW_IMAGE 2. Lambda function code (Python): def lambda_handler(event, context): for record in event['Records']: if record['eventName'] == 'INSERT': product = record['dynamodb']['NewImage'] print(f"New product added: {product['ProductName']['S']}")
Pass the test and this pattern moves unknown