03 / 06

How does S3 trigger a Lambda function?

Difficulty: 5/10
S3 event notifications, Lambda permissions, Cross-account triggers

S3 Event-Driven Invocation of Lambda

Amazon S3 can trigger a Lambda function automatically in response to specific events like object uploads, deletions, or updates. This allows developers to build serverless, event-driven architectures where file operations directly invoke backend logic without manual polling.

Common S3 Events That Can Trigger Lambda
  1. 1

    s3:ObjectCreated:* – triggers when an object is uploaded or copied

  2. 2

    s3:ObjectRemoved:* – triggers when an object is deleted

  3. 3

    s3:ObjectRestore:* – triggers when an archived object is restored

  4. 4

    s3:Replication:* – triggers when an object is replicated

Steps to Configure S3 to Trigger Lambda
  1. 1

    Go to the S3 bucket in the AWS Console

  2. 2

    Select the 'Properties' tab and find 'Event notifications'

  3. 3

    Create a new event and specify the event type (e.g., ObjectCreated)

  4. 4

    Choose 'Lambda function' as the destination

  5. 5

    Select the Lambda function and grant it permission to be invoked by S3

Sample S3 Event Payload Sent to Lambda

Scenario Questions

0-2 years experience

  1. 1You need to run a Lambda function every time a new object is uploaded to an S3 bucket. Walk me through the steps you would take to set that up.
  2. 2If you accidentally set the event notification on the wrong prefix, what would happen when objects are added elsewhere in the bucket?

2-5 years experience

  1. 1Our team noticed that a Lambda function isn’t being invoked for certain S3 PUT events. How would you troubleshoot the issue?
  2. 2Explain the trade‑offs between using S3 event notifications versus S3 Object Lambda for processing new objects.

5-8 years experience

  1. 1Design a solution to reliably process millions of S3 object creation events per hour with Lambda, ensuring ordering and handling throttling.
  2. 2How would you secure cross‑account S3 to Lambda triggers while minimizing permissions and avoiding circular dependencies?

8+ years experience

  1. 1We are migrating a legacy data pipeline that currently uses S3 notifications to trigger a fleet of Lambda functions across multiple regions. What architectural changes would you recommend to improve scalability, observability, and fault tolerance?
  2. 2Discuss the long‑term maintenance implications of using S3 event notifications versus an event‑bus (e.g., EventBridge) for triggering Lambda, especially in a multi‑team environment.

Follow-up Questions

  • What limits should we be aware of when using S3‑to‑Lambda triggers?
  • How does Lambda handle retries if the function fails?
  • Can you change the trigger without redeploying the function?
Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.