Integrating S3 Event Notifications with AWS Lambda
Overview of S3 Event Notifications
- S3 event notifications are used to receive alerts for various bucket events such as object creation, deletion, restoration, and replication.
- Notifications can be filtered by object key prefixes and suffixes.
- Common use case: Generating thumbnails for new images uploaded to S3.

Delivery Targets for S3 Events
- Amazon SNS: Events can be published to SNS topics to implement a fan-out pattern to multiple subscribers or Amazon SQS queues.
- Amazon SQS: Events can be sent to SQS queues for processing, and a Lambda function can poll the queue to process messages.
- AWS Lambda: S3 can directly invoke a Lambda function asynchronously to handle events.
Handling Failures
- Set up a dead-letter queue (DLQ), such as an SQS queue, to handle failed event processing.
Considerations
- S3 event notifications are typically delivered within seconds, but delays up to a minute or more can occur.
- Enable versioning on S3 buckets to prevent loss of notifications if multiple writes to the same object occur simultaneously.
Example Pattern
- An S3 bucket receives a new file.
- An event notification triggers a Lambda function.
- The Lambda function processes the file and performs actions such as:
- Inserting data into a DynamoDB table.
- Updating a table in an RDS database.
Resoruce Based Policy