<?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 Akashkola on Medium]]></title>
        <description><![CDATA[Stories by Akashkola on Medium]]></description>
        <link>https://medium.com/@akashkola321?source=rss-7f0ce16923e2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*F0uPwOpKX35WVT9c</url>
            <title>Stories by Akashkola on Medium</title>
            <link>https://medium.com/@akashkola321?source=rss-7f0ce16923e2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 07:30:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@akashkola321/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[A Complete Guide to Amazon S3 Event Notifications: Ordering, Duplicates, Filters, Integrations…]]></title>
            <link>https://medium.com/@akashkola321/a-complete-guide-to-amazon-s3-event-notifications-ordering-duplicates-filters-integrations-8191b9304d2c?source=rss-7f0ce16923e2------2</link>
            <guid isPermaLink="false">https://medium.com/p/8191b9304d2c</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[s3]]></category>
            <dc:creator><![CDATA[Akashkola]]></dc:creator>
            <pubDate>Wed, 26 Nov 2025 17:47:14 GMT</pubDate>
            <atom:updated>2025-11-26T17:47:14.882Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Complete Guide to Amazon S3 Event Notifications: Ordering, Duplicates, Filters, Integrations, EventBridge, and Best Practices</h3><p>Amazon S3 event notifications are one of the most commonly used building blocks in AWS serverless and event-driven architectures. Whether you are triggering downstream pipelines, updating databases, or reacting to object changes, it’s critical to understand how S3 events actually work — including their pitfalls around ordering and deduplication, configuration limits, prefix/suffix rules, and integration specifics for SNS, SQS, and EventBridge.</p><p>This guide brings together <strong>every important S3 event-notification rule, behavior, constraint, and event-payload detail</strong>, along with references to AWS best-practice architectures for handling ordering and duplicates.</p><h3>1. Delivery Guarantees and Core Behavior</h3><h3>1.1 At-least-once delivery</h3><p>Amazon S3 delivers event notifications <strong>at least once</strong>, which means:</p><ul><li>You may receive <strong>duplicate events</strong> for the same object.</li><li>You may receive events <strong>out of order</strong> relative to when they actually happened.</li><li>Ordering is <em>not</em> guaranteed across any event type.</li></ul><p>S3 retries deliveries internally, which can result in the same event being pushed multiple times.</p><h3>Why this matters</h3><p>If your system depends on strict ordering, or must avoid duplicate processing (for example, image conversion, metadata extraction, database indexing), then your downstream logic must be <strong>idempotent</strong> and should track the event sequencer (explained later).</p><h3>2. Notification Configuration Rules</h3><h3>2.1 One destination per event notification rule</h3><p>Each S3 notification rule can target only:</p><ul><li>one SQS queue, <strong>or</strong></li><li>one SNS topic, <strong>or</strong></li><li>one Lambda function.</li></ul><p>If you need multiple destinations, you can:</p><ul><li>create <strong>multiple notification rules</strong> (within the same bucket),</li><li>or send to <strong>EventBridge</strong>, which can fan out to many targets.</li></ul><h3>2.2 You can reuse the same events across multiple rules</h3><p>Yes — you can create multiple rules with the <em>same</em> event types, as long as:</p><ul><li>their prefixes and suffixes do <strong>not overlap</strong><br> (AWS strictly enforces this).</li></ul><h3>3. Activation Delay and Test Events</h3><h3>3.1 5-minute propagation time</h3><p>After creating or modifying a bucket notification configuration:</p><ul><li>It usually takes <strong>about 5 minutes</strong> for changes to become active.</li></ul><h3>3.2 S3 sends a s3:TestEvent</h3><p>When notifications are first enabled, S3 sends a special event:</p><pre>{<br>  &quot;Service&quot;: &quot;Amazon S3&quot;,<br>  &quot;Event&quot;: &quot;s3:TestEvent&quot;,<br>  &quot;Time&quot;: &quot;...&quot;,<br>  &quot;Bucket&quot;: &quot;bucket-name&quot;<br>}</pre><p>This event:</p><ul><li>Does <strong>not</strong> follow the standard Records[] array structure.</li><li>Your consumer must be able to detect and ignore it.</li></ul><h3>4. Prefix/Suffix Filtering Rules</h3><h3>4.1 URL-encoding is required</h3><p>If your prefix or suffix contains:</p><ul><li>a <strong>space</strong> → replace with +</li><li>any special characters → must be <strong>URL encoded</strong></li></ul><h3>4.2 Filters cannot overlap</h3><p>You cannot define filtering rules where:</p><ul><li>prefixes overlap</li><li>suffixes overlap</li><li>or prefix and suffix combinations overlap</li></ul><p>AWS validates and rejects such configurations.</p><h3>4.3 One prefix/suffix per rule</h3><p>Each rule supports <strong>one prefix</strong> and <strong>one suffix</strong> only.</p><p>If you need complex matching such as:</p><pre>images/, photos/, pictures/t</pre><p>Use:</p><ul><li>multiple S3 rules, or</li><li><strong>EventBridge</strong>, which supports multi-value filtering.</li></ul><h3>5. Limits</h3><pre>| Item                          | Limit   | Adjustable |<br>| ----------------------------- | ------- | ---------- |<br>| Notification rules per bucket | **100** | ❌ No      |</pre><h3>6. SNS as a Destination</h3><p>Amazon S3 supports:</p><ul><li><strong>SNS Standard topics only</strong></li></ul><p>SNS FIFO topics are <strong>not supported</strong>.</p><p>Both bucket and topic must be in the <strong>same AWS Region</strong>.</p><h3>7. SQS as a Destination</h3><h3>7.1 Must be in same Region</h3><p>S3 bucket and SQS queue must be colocated.</p><h3>7.2 FIFO SQS queues are not supported</h3><p>S3 → SQS FIFO <strong>does not work</strong> directly.<br> If you must use FIFO queues:</p><ul><li>Use <strong>EventBridge</strong>, then target a FIFO queue.</li></ul><h3>7.3 Queue policy rules</h3><p>S3 must be allowed to send messages to the SQS queue.</p><p>Depending on whether you use ArnLike or StringLike, matching behaves differently:</p><h4>ArnLike matching rules</h4><p>Only Region and resource path can partially match.<br> Everything else must match exactly:</p><ul><li>partition</li><li>service</li><li>account ID</li><li>resource type</li><li>partial resource ID</li></ul><h4>StringLike matching rules</h4><p>Wildcard matching ignores ARN structure entirely.</p><pre>&quot;Condition&quot;: {<br>  &quot;StringLike&quot;: {<br>    &quot;aws:SourceArn&quot;: &quot;arn:aws:s3:*:*:amzn-s3-demo-bucket&quot;<br>  }<br>}</pre><p>This is far more flexible.</p><h3>7.4 KMS-encrypted queues</h3><p>If your SQS queue is encrypted using KMS:</p><ul><li>You must grant s3.amazonaws.com permission to use kms:GenerateDataKey and kms:Decrypt.</li></ul><p>Example:</p><pre>{<br>  &quot;Effect&quot;: &quot;Allow&quot;,<br>  &quot;Principal&quot;: { &quot;Service&quot;: &quot;s3.amazonaws.com&quot; },<br>  &quot;Action&quot;: [&quot;kms:GenerateDataKey&quot;,&quot;kms:Decrypt&quot;],<br>  &quot;Resource&quot;: &quot;*&quot;<br>}</pre><h3>8. S3 Event Notification Payload Structure</h3><p>A typical event payload looks like:</p><pre>{<br>  &quot;Records&quot;:[<br>    {<br>      &quot;eventVersion&quot;: &quot;2.1&quot;,<br>      &quot;eventSource&quot;: &quot;aws:s3&quot;,<br>      &quot;awsRegion&quot;: &quot;us-west-2&quot;,<br>      &quot;eventTime&quot;: &quot;ISO-8601 timestamp&quot;,<br>      &quot;eventName&quot;: &quot;Event type&quot;,<br>      &quot;userIdentity&quot;: { ... },<br>      &quot;requestParameters&quot;: { ... },<br>      &quot;responseElements&quot;: { ... },<br>      &quot;s3&quot;: {<br>        &quot;configurationId&quot;: &quot;config-id&quot;,<br>        &quot;bucket&quot;: { ... },<br>        &quot;object&quot;: {<br>          &quot;key&quot;: &quot;URL-encoded-key&quot;,<br>          &quot;size&quot;: 123,<br>          &quot;eTag&quot;: &quot;...&quot;,<br>          &quot;versionId&quot;: &quot;...&quot;,<br>          &quot;sequencer&quot;: &quot;hex-value&quot;<br>        }<br>      },<br>      &quot;glacierEventData&quot;: { ... }<br>    }<br>  ]<br>}</pre><h3>9. Event Versions (2.1, 2.2, 2.3)</h3><h3>S3 uses:</h3><ul><li><strong>2.1</strong> → default for most events</li><li><strong>2.2</strong> → Cross-Region Replication</li><li><strong>2.3</strong> → Lifecycle, Intelligent-Tiering, ACL, Tagging, Restore Delete</li></ul><h3>Recommended parsing logic:</h3><ul><li>Compare <strong>major version</strong> with equality (2.)</li><li>Compare <strong>minor version</strong> with &gt;=</li></ul><h3>Sequencer</h3><p>Each create or delete event includes a sequencer field:</p><ul><li>Used to determine ordering <em>for the same key</em></li><li>Can be different lengths → left-pad shorter with zeros before comparison</li><li>Supports lexicographical comparison</li></ul><blockquote><em>If you’re updating an index or database with object metadata, compare sequencer values to drop out-of-order events</em></blockquote><h3>10. Supported Event Types</h3><h3>Object Creation</h3><ul><li>s3:TestEvent</li><li>s3:ObjectCreated:*</li><li>s3:ObjectCreated:Put</li><li>s3:ObjectCreated:Post</li><li>s3:ObjectCreated:Copy</li><li>s3:ObjectCreated:CompleteMultipartUpload</li></ul><h3>Object Deletion</h3><ul><li>s3:ObjectRemoved:*</li><li>s3:ObjectRemoved:Delete</li><li>s3:ObjectRemoved:DeleteMarkerCreated</li></ul><h3>Object Restore</h3><ul><li>s3:ObjectRestore:*</li><li>s3:ObjectRestore:Post</li><li>s3:ObjectRestore:Completed</li><li>s3:ObjectRestore:Delete</li></ul><h3>Other</h3><ul><li>s3:ReducedRedundancyLostObject</li><li>s3:Replication:*</li><li>s3:LifecycleExpiration:*</li><li>s3:LifecycleTransition</li><li>s3:IntelligentTiering</li><li>s3:ObjectTagging:*</li><li>s3:ObjectAcl:Put</li></ul><p>11. CloudFormation Example</p><pre>MyBucket:<br>  Type: AWS::S3::Bucket<br>  Properties:<br>    NotificationConfiguration:<br>      QueueConfigurations:<br><br>        # Rule 1<br>        - Event: s3:ObjectCreated:*<br>          Queue: !GetAtt MyQueue.Arn<br>          Filter:<br>            S3Key:<br>              Rules:<br>                - Name: prefix<br>                  Value: images/<br><br>        # Rule 2<br>        - Event: s3:ObjectCreated:*<br>          Queue: !GetAtt MyQueue.Arn<br>          Filter:<br>            S3Key:<br>              Rules:<br>                - Name: prefix<br>                  Value: videos/</pre><h3>12. S3 → EventBridge Integration</h3><p>EventBridge receives a broader set of events than S3 notifications alone:</p><h3>Delivered to EventBridge</h3><ul><li>Object Created</li><li>Object Deleted (DeleteObject)</li><li>Object Deleted (Lifecycle expiration)</li><li>Object Restore Initiated</li><li>Object Restore Completed</li><li>Object Restore Expired</li><li>Storage Class Changed</li><li>Access Tier Changed</li><li>ACL Updated</li><li>Tags Added</li><li>Tags Deleted</li></ul><h3>Why use EventBridge?</h3><ul><li>Supports multiple targets</li><li>Supports SQS FIFO queues</li><li>Advanced filtering</li><li>No prefix/suffix overlap issues</li><li>No configuration limits</li><li>No additional IAM permissions needed (S3 → EventBridge)</li></ul><p>13. EventBridge Event Format</p><pre>{<br>  &quot;version&quot;: &quot;0&quot;,<br>  &quot;id&quot;: &quot;uuid&quot;,<br>  &quot;detail-type&quot;: &quot;Object Created&quot;,<br>  &quot;source&quot;: &quot;aws.s3&quot;,<br>  &quot;account&quot;: &quot;111122223333&quot;,<br>  &quot;time&quot;: &quot;2021-11-12T00:00:00Z&quot;,<br>  &quot;region&quot;: &quot;ca-central-1&quot;,<br>  &quot;resources&quot;: [&quot;arn:aws:s3:::bucket&quot;],<br>  &quot;detail&quot;: { ... }<br>}</pre><h3>4. Handling Event Ordering &amp; Duplicates (AWS Best Practice)</h3><p>AWS published an excellent architecture for solving out-of-order or duplicate S3 events:</p><p>🔗 <strong>Manage event ordering and duplicate events with Amazon S3 Event Notifications</strong><br> <a href="https://aws.amazon.com/blogs/storage/manage-event-ordering-and-duplicate-events-with-amazon-s3-event-notifications/?utm_source=chatgpt.com">https://aws.amazon.com/blogs/storage/manage-event-ordering-and-duplicate-events-with-amazon-s3-event-notifications/</a></p><h3>The solution uses:</h3><ul><li>S3 → EventBridge</li><li>EventBridge → Lambda</li><li>Lambda → DynamoDB (sequencer tracking)</li></ul><h3>How it works:</h3><ol><li>When a new event arrives, Lambda looks up the latest sequencer stored for that object key.</li><li>If the new event <strong>is older</strong> (lexicographically smaller), it’s ignored.</li><li>If it’s new:<br>Process it.<br>Update the DynamoDB entry.</li></ol><p>This ensures:<br> ✔ Correct ordering<br> ✔ Duplicate suppression<br> ✔ Idempotent processing<br> ✔ High-scalability with no S3-side constraints</p><p>This architecture is recommended when building production-grade systems that must stay consistent despite S3’s at-least-once and unordered delivery model.</p><h3>Conclusion</h3><p>Amazon S3 event notifications are powerful but come with strict behaviors and constraints:</p><ul><li>Delivery is at least once → duplicates occur</li><li>Events may arrive out of order</li><li>Prefix/suffix filters cannot overlap</li><li>Only Standard SNS/SQS queues allowed</li><li>FIFO queues require EventBridge</li><li>Configuration changes require ~5 minutes</li><li>Test events must be handled separately</li><li>Sequencer values must be compared carefully</li></ul><p>For complex or high-reliability architectures, <strong>EventBridge</strong> is often the superior choice due to richer events, advanced filtering, multi-target routing, and FIFO queue support.</p><p>Finally, AWS’s recommended approach using EventBridge + DynamoDB provides a scalable and robust pattern for eliminating duplicates and maintaining strict per-object ordering.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8191b9304d2c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>