AWS Lambda Event Sources
An event source is the AWS service or resource that invokes a Lambda function, such as an HTTP request, a queue message or a schedule. In serverless.yml, each function lists its event sources under events, one list item per trigger, keyed by the event name:
functions:
processOrder:
handler: handler.handler
events:
- httpApi: 'POST /orders'
- sqs: arn:aws:sqs:us-east-1:123456789012:orders
The pages in this section document each event key. For how events work across all sources, see AWS Lambda events.
HTTP event sources
- HTTP API (API Gateway v2):
httpApiroutes HTTP requests from an Amazon API Gateway HTTP API to a function. - REST API (API Gateway v1):
httproutes HTTP requests from an Amazon API Gateway REST API, for features only REST APIs have. - WebSocket API:
websockethandles connect, disconnect and message routes of an API Gateway WebSocket API. - Application Load Balancer:
albregisters a function as the target of a listener rule on an existing Application Load Balancer. - CloudFront (Lambda@Edge):
cloudFrontruns a function at CloudFront edge locations on viewer and origin requests and responses.
Messaging and stream event sources
- SQS:
sqsprocesses messages from an Amazon SQS queue in batches. - SNS:
snsinvokes a function for each message published to an Amazon SNS topic. - Kinesis and DynamoDB Streams:
streamprocesses records from a Kinesis data stream or a DynamoDB table stream. - MSK:
mskconsumes a topic of an Amazon MSK (Managed Streaming for Apache Kafka) cluster. - Kafka:
kafkaconsumes a topic of a self-managed Apache Kafka cluster. - ActiveMQ:
activemqconsumes a queue of an Amazon MQ for ActiveMQ broker. - RabbitMQ:
rabbitmqconsumes a queue of an Amazon MQ for RabbitMQ broker.
Storage and data event sources
- S3:
s3invokes a function for Amazon S3 event notifications, such as an object created or removed, on a new or existing bucket. - CloudWatch Logs:
cloudwatchLogstreams log events from a CloudWatch Logs log group through a subscription filter.
Scheduling and EventBridge event sources
- Schedule:
scheduleruns a function on arate()orcron()schedule. - EventBridge:
eventBridgeinvokes a function for events on the default or a custom Amazon EventBridge event bus that match a pattern. - CloudWatch Events:
cloudwatchEventinvokes a function for AWS service events on the default event bus that match a pattern.
Other AWS service event sources
- Cognito User Pool:
cognitoUserPoolattaches a function to an Amazon Cognito user pool trigger, such as pre sign-up or post confirmation. - AWS IoT rule:
iotinvokes a function for MQTT messages that match an AWS IoT rule's SQL statement. - IoT fleet provisioning:
iotFleetProvisioningmakes a function the pre-provisioning hook of an AWS IoT fleet provisioning template. - Alexa Skill:
alexaSkilllets an Alexa custom skill invoke a function. - Alexa Smart Home:
alexaSmartHomelets an Alexa smart home skill invoke a function.