Hello! Welcome back to your preparation course for the AWS Certified Data Engineer - Associate exam.
In our last lesson, we focused on how to store data cost-effectively in your data lake using S3 storage classes and lifecycle policies. We covered the "data at rest" part of the equation. Now, we'll shift our focus to making your data lake active and responsive.
Today's learning outcome is to implement S3 event notifications to trigger data processing workflows. This is the mechanism that allows your data lake to react automatically when new data arrives or changes. For a data engineer, mastering this concept is fundamental for building automated ingestion pipelines, ETL triggers, and real-time processing systems. Since you're already very familiar with S3, we'll dive right into the architectural patterns and best practices crucial for the exam.
What are S3 Event Notifications?
Instead of constantly polling an S3 bucket to check for new files—a costly and inefficient approach—S3 Event Notifications use a push-based model. You configure your S3 bucket to send a message automatically when a specific event occurs, such as a new object being uploaded (s3:ObjectCreated:*) or an object being deleted (s3:ObjectRemoved:*).
This capability is the cornerstone of event-driven architecture on AWS. For an overview of the benefits and common use cases in data engineering, the article "Configuring Amazon S3 Event Notifications" (resource LINK) provides excellent context on automating ETL, security monitoring, and serverless pipelines.
The key components of an event notification are:
- Event: The action that happens in S3 (e.g.,
s3:ObjectCreated:Put). - Filter: Rules to limit notifications to objects with a specific prefix (folder) or suffix (file extension).
- Destination: The AWS service that receives the notification message.
Choosing the Right Destination
The choice of destination is a critical architectural decision and a frequent topic in exam questions. S3 can send notifications directly to three main services: AWS Lambda, Amazon SQS (Simple Queue Service), and Amazon SNS (Simple Notification Service).

Here's a breakdown of when to use each:
| Destination | Primary Use Case | Key Characteristics |
|---|---|---|
| AWS Lambda | Direct, immediate processing. | - Simple, direct invocation of a function. - Good for stateless, lightweight transformations. - Risk of lost events if the function fails and has no retry/DLQ configured. - Best for single-action responses. |
| Amazon SQS | Decoupled, durable processing for a single consumer. | - The event message is stored in a queue until a consumer processes it. - Provides durability and resilience against downstream failures. - Supports Dead-Letter Queues (DLQs) to handle poison pills (bad messages). - Ideal for ensuring every event is processed by one system, even during outages. |
| Amazon SNS | Fan-out to multiple consumers. | - Publishes the event message to a topic. - Multiple subscribers (e.g., several SQS queues, Lambda functions, email) can receive the same message. - Perfect when an S3 event needs to trigger several different, independent workflows simultaneously. |
A fourth, more modern and flexible option is to use Amazon EventBridge. While we'll cover EventBridge in more detail later, know that it's often the recommended choice for complex scenarios as it offers advanced filtering and routing to many more destination types.
Pattern 1: Direct Processing with AWS Lambda
This is the most straightforward pattern: a file lands in S3, and a Lambda function is immediately triggered to process it. This is great for tasks like resizing an image, validating a file's format, or loading a small CSV into DynamoDB.
The following video provides a step-by-step walkthrough of this exact scenario.
AWS S3 File Upload + Lambda Trigger - Step by Step Tutorial
The video 'AWS S3 File Upload + Lambda Trigger' from Be A Better Dev is a practical guide to setting up the S3-to-Lambda pattern. It covers creating the function, setting permissions, configuring the trigger, and processing the event.
Please watch from 00:35 to 12:43. As you watch, focus on these key steps: IAM Role (00:35): Note the permissions the Lambda function needs to read the S3 object (s3:GetObject). Event Structure (02:24): Pay close attention to the JSON event payload and how to extract the bucket name and object key. Trigger Configuration (03:53): Observe how the S3 trigger is added to the Lambda, including filtering by event type, prefix, and suffix. Recursive Invocation Warning (05:50): This is a critical point. The video explains why your Lambda function should never write back to the same S3 prefix that triggers it, as this can cause an infinite loop and rack up costs. Code and Testing (06:53): See how the code uses the event data to fetch and process the S3 object, and how the entire flow is tested.
Pattern 2: Decoupled Processing with Amazon SQS
For more robust data pipelines, you'll want to decouple the trigger from the processing logic. Sending the S3 event to an SQS queue achieves this. If your processing application is down, the messages simply wait in the queue until it's back online.
Let's walk through setting this up. A common pitfall here is misconfiguring the permissions between S3 and SQS.
This 'S3 to SQS Trigger Tutorial' video, also from Be A Better Dev, clearly demonstrates how to configure S3 to send notifications to an SQS queue.
Please watch from 02:10 to 13:52. Pay special attention to the following: Event Configuration (02:10): How to create the event notification on the S3 bucket, selecting event types and the SQS destination. Destination Comparison (04:49): The video gives a good summary of why you might choose SQS, SNS, or Lambda, reinforcing the concepts we discussed earlier. SQS Access Policy (07:39): This is the most important part. The video shows the error you get if the policy is missing and then walks you through editing the SQS queue's resource-based policy to explicitly grant the S3 service (s3.amazonaws.com) permission to send messages to it. This is a classic exam topic. Testing (11:23): See how uploading a file to S3 results in a message appearing in the SQS queue.
Advanced Pattern: Fan-Out with SNS and SQS
What if uploading a single file needs to kick off multiple, independent processes? For example, a new sales data file might need to be:
- Ingested into the data warehouse.
- Analyzed for fraudulent transactions.
- Added to a queue for an ML model to retrain.
This is a perfect use case for the "fan-out" pattern using SNS.

The flow is: S3 -> SNS Topic -> (Multiple SQS Queues) -> (Multiple Consumers). This architecture is highly scalable and decouples all components. A full walkthrough is extensive, but the article "Configuring Amazon S3 Event Notifications" (resource LINK) details this S3 → SNS → SQS → Lambda workflow in its third section if you'd like to see the configuration steps.
Crucial Exam Concepts and Best Practices
To succeed on the certification exam, you need to know more than just the setup. Here are the critical details you must understand. The article "A Complete Guide to Amazon S3 Event Notifications" (LINK) is an excellent resource covering these points in depth.
A Complete Guide to Amazon S3 Event Notifications
This article from Akash Kola is a dense, exam-focused summary of the rules and behaviors of S3 Event Notifications. It's perfect for reinforcing your knowledge.
Please read the following sections from the article: '1. Delivery Guarantees and Core Behavior' to understand the 'at-least-once' delivery model. '2. Notification Configuration Rules' and '4. Prefix/Suffix Filtering Rules' to learn about the constraints on rules. '7. SQS as a Destination' for details on queue policies. '12. S3 → EventBridge Integration' to understand why EventBridge is often a better choice. '14. Handling Event Ordering & Duplicates' to see a best-practice architecture for building idempotent systems.
Key Exam Takeaways from the Article:
- At-Least-Once Delivery: S3 guarantees that an event will be delivered at least once. This means you may receive duplicate events for the same S3 action. Your downstream processing logic must be idempotent—meaning, processing the same event multiple times should not produce different results or side effects.
- No Guaranteed Ordering: Events are not guaranteed to arrive in the order they occurred. To handle this, the event payload contains a
sequencerfield that you can use to determine the correct order for events related to the same object key. - Configuration Limits:
- Each rule can only have one destination.
- Filter rules (prefix/suffix combinations) for the same event type cannot overlap.
- There is a limit of 100 notification rules per bucket.
- Destination Constraints:
- Destinations (SNS/SQS) must be in the same AWS Region as the S3 bucket.
- S3 cannot publish directly to FIFO SQS queues or SNS topics. You must use EventBridge as an intermediary to do this.
- EventBridge is the Modern Solution: For any complex routing, filtering, or fan-out, using EventBridge as the destination is the recommended best practice. It overcomes many of the limitations of direct S3 notifications.
Test your understanding!
You are designing a data ingestion pipeline. When a new JSON file is uploaded to the s3://my-bucket/raw/ prefix, you need to trigger two separate processes:
- A Lambda function that validates the JSON schema.
- A Glue ETL job that loads the data into a Parquet-based table.
Which service should you configure as the S3 event notification destination to achieve this most effectively?
Show answer
The best destination is Amazon SNS.
Here's why: The requirement is to trigger two separate processes from a single S3 event. This is a classic fan-out scenario. By sending the notification to an SNS topic, you can create two subscriptions: one for the validation Lambda function and another that sends a message to an SQS queue, which in turn could trigger the Glue job (e.g., via another Lambda or a custom orchestrator). Using Lambda or SQS directly would not work, as a single event rule can only have one destination.
Conclusion
You've now learned how to build reactive, event-driven data pipelines using S3 Event Notifications. This is a powerful technique for automating your data engineering workflows and is a concept you can expect to see in various forms on the certification exam.
Key Takeaways:
- Automate, Don't Poll: Use S3 Event Notifications to trigger workflows instead of inefficiently checking for new files.
- Choose the Right Destination Pattern:
- Lambda for simple, direct processing.
- SQS for durable, decoupled single-consumer workloads.
- SNS for fanning out to multiple, independent consumers.
- Design for Failure (and Duplicates): S3 provides at-least-once delivery, so your consumers must be idempotent to handle potential duplicate events.
- Permissions are Key: Remember that S3 needs explicit permission via resource-based policies to send notifications to Lambda, SQS, or SNS.
- Use EventBridge for Complex Needs: For advanced filtering and routing, consider EventBridge as your go-to destination.
In our next lesson, we'll explore another way to interact with data in S3. We'll cover how to apply S3 Select and Glacier Select for efficient data retrieval, allowing you to query subsets of data directly within an object without having to download the entire file.