Course contentsShow
← Cloud and Infrastructure
Lesson 506 of 2,9899. Serverless ComputeFree lesson

AWS Lambda: Event Sources and Triggers

Understand synchronous vs asynchronous invocation, event source mappings, and integration with AWS services like S3, API Gateway, and DynamoDB.

AWS Lambda: Event Sources and Triggers

What you'll learn: How AWS Lambda functions get invoked by different AWS services and the difference between synchronous and asynchronous execution patterns.

How Lambda Gets Called

Lambda functions don't run on their own—they need a trigger to wake them up. Think of it like a doorbell: the function is your house, and event sources are the various buttons (S3 upload, API request, database change) that ring the bell.

Synchronous vs Asynchronous Invocation

Synchronous invocation means the caller waits for your function to finish and gets the response immediately. API Gateway uses this model—a user makes a request, Lambda processes it, and the user receives the result.

Asynchronous invocation means the caller drops off an event and moves on without waiting. S3 uses this pattern—when you upload a file, S3 tells Lambda about it but doesn't wait for processing to complete. If the function fails, Lambda automatically retries (up to twice).

Event Source Mappings

For stream-based sources like DynamoDB Streams or SQS queues, Lambda uses event source mappings. This is a configuration that tells Lambda to continuously poll the source for new records and invoke your function with batches of events. Lambda manages the polling and cursor position for you.

Common Integrations

  • S3: Triggers on object uploads (async)
  • API Gateway: Triggers on HTTP requests (sync)
  • DynamoDB Streams: Polls for table changes (event source mapping)
  • SQS: Polls queue for messages (event source mapping)
  • EventBridge: Scheduled or event-driven invocations (async)

Key Takeaway: Lambda event sources determine how and when your function runs—synchronously for immediate responses, asynchronously for background processing, or via event source mappings for continuous stream polling.