Posts

Showing posts with the label Event Driven

DynamoDB Streams

Image
  DynamoDB Streams are one of the most powerful—but often under‑explained—features in DynamoDB. A DynamoDB Stream captures every change to items in a table: INSERT MODIFY REMOVE You can then process these changes using: AWS Lambda Kinesis Custom consumers This is how you build event‑driven architectures with DynamoDB. Enable Streams on the Table: You choose a stream view type, e.g.: NEW_IMAGE → only the new item OLD_IMAGE → only the old item NEW_AND_OLD_IMAGES → both KEYS_ONLY → only keys I have table created by the name called " order ". I have enabled "Streams" to capture the changes to the table. And I have added the lambda function to process the streams. Lambda gets triggered , whenever there is a change in the DB items. Below is the lambda snippet: import json def lambda_handler(event, context):     for record in event[ "Records" ]:         event_name = record[ "eventName" ]         keys = record[ "dynamo...

S3 - Event Driven Action

Image
  In this blog, we will see how to use S3 with event driven architecture. Flow is as below: 1) Application running on EC2 instance uploads object to a prefix called " raw_data " into a S3 bucket. 2) Once the object is uploaded, S3 event is detected by the Event Bridge rule. 3) Event bridge rule is configured to listen for "S3:ObjectCreate" event with destination as Lambda. 4) Lambda is configured to read data from the " raw_data " folder and process it. 5) Processed data is saved into a file under the folder " processed_data ". 6) Both the folders " raw_data " and " processed_data " exist in the same bucket " demo-event-application" Here is the bucket. EC2 instance is attached with the IAM EC2 instance profile to perform S3 actions. This profile/role has admin S3 access for S3 actions. Attaching the role to the EC2 instance. Let's login to the EC2 instance and verify the S3 actions. It worked. Here is the snippe...

AWS Lambda Integration With EventBridge

Image
                                                                                  In our previous blog, we explored the concept of Lambda versioning. In real-world scenarios, Lambda functions are typically triggered either on a schedule or in response to specific events. In this post, we’ll walk through how to invoke a Lambda function using both scheduled triggers and event-driven mechanisms. This is our goal. Our lambda scans for any RUNNING, PENDING instances of type "T3.SMALL". If there are any instances of that type, it triggers an email. Involved services: 1) Lambda - Python code to scan for  RUNNING, PENDING instances of type "T3.SMALL" 2) Event Bridge - Scheduler and Event Based. 3) SNS - Notification Service. Here is the simple...