<?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 Rajesh Pandey on Medium]]></title>
        <description><![CDATA[Stories by Rajesh Pandey on Medium]]></description>
        <link>https://medium.com/@rajeshpandey2053?source=rss-71f1c543fae1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*spHotWeqe8V_K6d5.jpg</url>
            <title>Stories by Rajesh Pandey on Medium</title>
            <link>https://medium.com/@rajeshpandey2053?source=rss-71f1c543fae1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 10:58:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rajeshpandey2053/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[Exploring S3 access triggers. Do they exist?]]></title>
            <link>https://medium.com/@rajeshpandey2053/exploring-s3-access-triggers-do-they-exist-00d74eff74c3?source=rss-71f1c543fae1------2</link>
            <guid isPermaLink="false">https://medium.com/p/00d74eff74c3</guid>
            <category><![CDATA[aws-s3]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[aws-cloudtrail]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[Rajesh Pandey]]></dc:creator>
            <pubDate>Sun, 15 Oct 2023 00:06:40 GMT</pubDate>
            <atom:updated>2023-10-15T02:36:05.277Z</atom:updated>
            <content:encoded><![CDATA[<p>The simple answer is no for now. But, we have a workaround at our disposal to accomplish this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Yngl21BXB4zOrr0L" /><figcaption>Photo by <a href="https://unsplash.com/@lamunix?utm_source=medium&amp;utm_medium=referral">Ana Municio</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>Introduction</strong></p><p>Amazon S3 (Simple Storage Service) is a popular cloud storage solution allowing users to store and retrieve data easily. While S3 provides various features for managing data within buckets, I have always wondered if there are built-in access triggers for S3. In this article, we will explore this topic in detail and provide insights into whether S3 access triggers exist. If not, we will discuss how to achieve them.</p><p><strong>What are S3 Triggers?</strong></p><p>S3 triggers are mechanisms that enable automated actions or responses to specific events or conditions. For instance, when an object is created or deleted, within an S3 bucket, S3 triggers could initiate various actions, such as sending notifications, running Lambda functions, or modifying object permissions. For example, you can use a Lambda function with an Amazon S3 trigger to convert uploaded documents into different formats.</p><p><strong>The Reality of S3 Access Triggers</strong></p><p>Amazon S3 lacks native S3 triggers for downloads; it only provides triggers for create and delete events, as shown in the figure below. <em>To work around this, you can create a solution using CloudTrail and another S3 bucket to trigger a Lambda function when users download data from S3.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2GtOxwnGd4qGHiK1OjcDGg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*CB6rM1Luhksj-GLdSKM6NQ.png" /></figure><blockquote><strong>You have got the idea now. Lets do it!</strong></blockquote><ol><li>First step is to setup a Cloudtrail event on the original S3 bucket. I am calling this as <em>original</em> and the later one as <em>logbucket</em> which we will use to trigger a lambda function.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yl6UQDvW5znanuLPPDZ2UQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EJkFS0smOKW4sWc6U3Pelg.png" /></figure><p>2. While setting up the trail attributes, you can create a new s3 bucket or use existing bucket to store the logs of the original S3 bucket. I am using existing bucket(for eg: testinglogsrp). Do not forget to watch out where your logs will be stored.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6u7DoD03RF1tAMw7xGy8rQ.png" /></figure><p>3. Now, create a lambda function with the basic information as shown in the diagram.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AUPaY3tz8JpbbofffpePZA.png" /></figure><p>Under S3 Trigger, choose the <em>logbucket</em> (not the <em>original</em> bucket) you have created to trigger the lambda function. You can even watch the specific location to create the triggers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hK9lu8D1UWH7ZNxIrR5ilQ.png" /></figure><p>4. Finally, in the Lambda code snippet, the process involves extracting the S3 key of the log object (the log file) from the event. Using the boto3 package, you can then proceed to download the log file and parse its contents. Within these log files, there are distinct event types for various operations performed in S3. Notably, there’s the <em>GetObject </em>event type specifically for file downloads. So, if the extracted <em>eventName</em> corresponds to <em>GetObject</em>, you’ve hit the mark — now, you have the freedom to execute any desired actions.</p><p><strong>Conclusion</strong></p><p>While native S3 access triggers don’t exist, you can use CloudTrail and a Lambda function combined with another S3 bucket to achieve the desired access triggers for downloads from an S3 bucket.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=00d74eff74c3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>