Common Lambda Triggers

~10 min read

The event sources that most commonly invoke a Lambda function in real applications.

API Gateway is the most common trigger for synchronous, request/response use cases — building a REST or HTTP API where each route maps to a Lambda function, giving you a fully serverless API backend with no load balancer or EC2 fleet at all.

S3 events fire when an object is created, deleted, or modified in a bucket — commonly used for processing uploaded files (generating thumbnails, extracting metadata, scanning for malware) immediately and automatically as they arrive.

SQS and SNS trigger Lambda for asynchronous, decoupled processing: SQS polls a queue and invokes your function with a batch of messages (useful for background job processing with built-in retry/dead-letter-queue support), while SNS pushes a message to a Lambda function the instant it's published (useful for fan-out notification patterns).

DynamoDB Streams trigger a Lambda function whenever an item in a table is inserted, updated, or deleted — commonly used to keep a search index or cache in sync with the source-of-truth table, or to trigger downstream business logic reactively.

EventBridge (including its scheduled 'cron' rules) triggers Lambda on a time-based schedule (e.g. 'every night at 2am') or in response to events from other AWS services and custom application events, making it the standard choice for both scheduled jobs and general event-bus-style architectures.

💬 Deep Dive with AI

Key points

  • API Gateway: synchronous HTTP request/response, serverless API backends
  • S3 events: react to file uploads/changes automatically
  • SQS/SNS: asynchronous decoupled processing, queue-based with retries, or pub/sub fan-out
  • DynamoDB Streams: react to table changes, e.g. to sync a search index
  • EventBridge: scheduled/cron jobs and general event-bus-style architectures