How to handle S3 events inside a Kubernetes Cluster?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
When an object is created or deleted in S3, code running inside a Kubernetes cluster often needs to react. The reliable pattern is usually not “have S3 call a pod directly,” but to place a durable AWS service such as SQS or EventBridge between S3 and the cluster. That gives you retries, buffering, and a cleaner security model.
Prefer Queue-Based Delivery
S3 can publish event notifications to services such as SQS, SNS, Lambda, and EventBridge. Inside Kubernetes, SQS is often the easiest target because pods can poll it safely without exposing an inbound HTTP endpoint.
A common production flow is:
- S3 emits an object event
- S3 sends it to SQS
- a deployment in the cluster polls SQS
- the worker processes the event and deletes the message
This pattern is resilient because the queue absorbs spikes and lets workers recover after restarts.
Why Direct Webhooks Are Usually Weaker
You can route events through API Gateway or another public endpoint and forward them to the cluster, but that usually creates more operational work:
- you need ingress and authentication
- transient pod failures can cause delivery issues
- retries become your problem instead of the queue’s problem
A direct webhook is still reasonable when you need immediate push delivery, but for most internal processing pipelines SQS is simpler.
Example Worker Using SQS
A small Python worker can poll SQS and read the S3 event payload.
This is intentionally simple, but it demonstrates the important contract: process the event and delete the message only after success.
Give Pods AWS Access Correctly
In Kubernetes, the worker needs permission to read from SQS and often permission to fetch the referenced object from S3. On EKS, the cleanest approach is usually IAM Roles for Service Accounts, often called IRSA.
A service account can then be attached to the deployment:
That avoids static AWS keys inside the cluster.
Think About Idempotency
S3 notifications are not a guarantee of exactly-once processing at the application level. Your consumer should be idempotent.
That means if the same event appears twice, the result should still be safe. For example:
- processing a file only if its output does not already exist
- storing processed object versions in a database
- using the object key plus event time as a deduplication key
Without idempotency, retries become bugs.
Alternative Architectures
SQS is a strong default, but it is not the only design:
- '
S3 -> Lambda -> internal APIwhen preprocessing or filtering is easier in Lambda' - '
S3 -> EventBridge -> multiple targetswhen several consumers need the same event stream' - '
S3 -> SNS -> SQSwhen fan-out is needed with independent queues'
Choose based on delivery pattern, not on whichever AWS service you used last time.
Common Pitfalls
- Exposing a pod directly to S3 events when a queue would be safer and simpler.
- Giving pods static AWS credentials instead of using workload identity such as IRSA.
- Deleting SQS messages before processing succeeds.
- Assuming S3 event delivery is exactly once and skipping idempotency.
- Ignoring backpressure when a burst of uploads can overwhelm a small worker deployment.
Summary
- The usual Kubernetes pattern is
S3 -> SQS -> worker pod. - Queue-based delivery is easier to secure and more resilient than direct inbound webhooks.
- Pods should use workload identity, not embedded AWS keys.
- Consumers must be idempotent because retries and duplicates are normal distributed-system behavior.
- Pick EventBridge, SNS, or Lambda only when the event-routing requirements justify the extra complexity.
Related reading
- How to identify schedulable nodes in Kubernetes
- How to identify the storage space left in a persistent volume claim?
- How to import a generated Kubernetes cluster's namespace in terraform
- How to improve random number generation in kubernetes cluster containers?
- How to handle UnprocessedItems using AWS JavaScript SDK dynamoDB?
- How to import existing VPC in aws cdk?
- how to implement a distributed system for a monitoring platform
- How to include files outside of Docker's build context?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.