<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Prathapn on Medium]]></title>
        <description><![CDATA[Stories by Prathapn on Medium]]></description>
        <link>https://medium.com/@prathapn01?source=rss-3f75c40bc30f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*EkaeRSiW3dQFJJ7t</url>
            <title>Stories by Prathapn on Medium</title>
            <link>https://medium.com/@prathapn01?source=rss-3f75c40bc30f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 15:04:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@prathapn01/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Dynamo DB Streams & Lambda for Efficient Data Processing]]></title>
            <link>https://medium.com/@prathapn01/dynamo-db-strems-lambda-for-efficient-data-processing-2bdea157b3bd?source=rss-3f75c40bc30f------2</link>
            <guid isPermaLink="false">https://medium.com/p/2bdea157b3bd</guid>
            <dc:creator><![CDATA[Prathapn]]></dc:creator>
            <pubDate>Fri, 05 Jul 2024 18:18:24 GMT</pubDate>
            <atom:updated>2024-07-06T13:14:38.093Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello Everyone, welcome to my blog on medium.com. In this article, I would like to describe an application design pattern that can be used for building an automated data processing pipeline</p><p>In the cloud-native architecture, the integration of AWS services like DynamoDB, Lambda, and data pipelines helps how businesses handle real-time data processing and transformation. One powerful pattern that exemplifies this synergy is the use of DynamoDB Streams to trigger Lambda functions, which subsequently initiate ETL (Extract, Transform, Load) or data engineering pipelines. Let’s delve into how this design pattern operates and its practical applications.</p><h3>Understanding DynamoDB Streams</h3><p>DynamoDB Streams provide a time-ordered sequence of item-level modifications in a DynamoDB table. Each modification is stored as a stream record, capturing details such as the nature of the change (insertion, modification, or deletion), the modified item, and other metadata. These streams are durable and automatically replicated across multiple Availability Zones, ensuring reliability and fault tolerance.</p><h3>The Lambda Trigger Mechanism</h3><p>Lambda functions can be seamlessly connected to DynamoDB Streams through event source mappings. This setup enables Lambda to automatically invoke a function in response to events from the stream, such as new records or changes in the DynamoDB table. Leveraging Lambda in this way ensures that data processing is event-driven, highly scalable, and operates in near real-time.</p><h3>Design Pattern: DynamoDB Streams + Lambda + Data Pipeline</h3><p><strong>Stream Configuration</strong>: First step is to create a dynamo DB table and enable “streams” on the table on the AWS console. This allows records to be added into the table. It can be done either on the console UI or AWS SDK, CLI etc., The following screen shot indicates how the dynamo DB table config looks when streams is enabled.</p><p>Click on “dynamo DB” -&gt; Click on “tables” -&gt; Click on “your table” -&gt; Click on “Exports and Streams” -&gt; Click on “Turn on”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hhMCTbe3ukGU0RuYCcOR5g.png" /></figure><p><strong>Lambda Function Setup</strong>: Create a Lambda function designed to handle events from DynamoDB Streams. The function should be equipped to process the stream records and initiate subsequent data processing tasks, such as ETL jobs or triggering a data pipeline. In this article, I will show an example Lambda function that gets triggered from Dynamo DB table, and it prints the event information, and attributes that are entered in the Dynamo DB table</p><p>Here is how the lambda function looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7-8Gw5Vyw5fsjdO5SJ1QqQ.png" /></figure><p>Add the code to the lambda function:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_GRzqE4TxHGBqdTcuOp3Dg.png" /></figure><p><strong>Add required Permissions</strong>: This is the most important step in this process The lambda function created will have a default execution role, and this IAM role should have permissions on the dynamo db table to ListStreams, GetRecords, DescribeStream, GetShardIterator etc.,</p><p>Here is the execution role for the created Lambda function:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UJ0i9Idjfvxjn0Wh7r-jmA.png" /></figure><p>Click on the IAM role, and add new policy “AWSLambdaDynamoDBExecutionRole” to the Lambda Execution role</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ezx5m9OwP26fWPzcCPD9Zg.png" /><figcaption>IAM role with policy for DynamoDB</figcaption></figure><h3>Create Trigger</h3><p>Now, add a trigger on the dynamo DB table, and mention the lambda function as the trigger. Go to the dynamo DB table, click on “exports and streams”, and go to the bottom of the screen, and click on “create trigger”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I_7BiCc4q1b8zax4R1YCiw.png" /></figure><p>Once the lambda function is added as a trigger, it looks as shown in above picture.</p><p>Once the trigger is created, an entry can be made to the dynamo db table, it will trigger the lambda function. We can find the evidence in the CloudWatch logs for the same lambda function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bdfpsNBTAk0Xm2-LyjC8sQ.png" /></figure><p>After clicking “create item”, add a partition key, sort key and add more attributes and save to add a record. The records in the table look like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JEZzoMkoWJKYqNVkT6duiQ.png" /></figure><p>Once the entry is added, immediately go to Lambda function, and browse the CloudWatch logs to determine whether the lambda function is executed, and whether the print statements are showing in the logs</p><p>Click on “Monitor” tab of the Lambda function, and the CloudWatch logs have links for each execution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3CzH-9R84yGfnd8upJWneQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*72sfjaH2YNFl7QHKCrY3zA.png" /></figure><h3>Benefits and Considerations</h3><ul><li><strong>Real-time Data Processing</strong>: Changes in DynamoDB are immediately reflected in the stream, triggering near real-time data processing through Lambda.</li><li><strong>Scalability</strong>: AWS manages the scaling of DynamoDB Streams and Lambda, ensuring that the system can handle varying workloads without manual intervention.</li><li><strong>Reliability</strong>: Built-in fault tolerance and durability of DynamoDB Streams ensure that no data changes are missed, providing a reliable foundation for event-driven architectures.</li></ul><h3>Conclusion</h3><p>The DynamoDB Streams + Lambda design pattern represents a robust solution for building scalable and responsive data processing pipelines in AWS. By leveraging event-driven architecture, businesses can achieve faster insights and operational efficiency, transforming raw data into actionable intelligence seamlessly. As cloud computing continues to evolve, mastering these patterns empowers organizations to harness the full potential of their data in a cost-effective and scalable manner.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2bdea157b3bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>