AWS Lambda Events
Events are what trigger your Lambda functions: an HTTP request, a message on a queue, a file upload, a schedule. You list them under each function's events in serverless.yml, and on serverless deploy the Framework creates the event source or connects an existing one, and gives it permission to invoke the function. This page lists every event type, with a link to its page.
A function can have several events, of the same or different types:
# serverless.yml
functions:
createUser:
handler: handler.createUser
events:
- httpApi: 'POST /users'
- sqs:
arn: arn:aws:sqs:us-east-1:123456789012:new-users
Each event is an object whose single key is the event type; its value holds that event's settings. The resources the Framework creates for events have predictable logical IDs, listed in the AWS CloudFormation resource reference, so you can refer to them with Ref and Fn::GetAtt or change them with resources.extensions.
HTTP and WebSocket events
- HTTP API (
httpApi): serve HTTP endpoints from an API Gateway HTTP API, with JWT and Lambda authorizers and CORS. - REST API (
http): serve HTTP endpoints from an API Gateway REST API, for API keys, usage plans, request validation and other REST API features. - WebSocket API (
websocket): handle connect, disconnect and message routes of an API Gateway WebSocket API. - Application Load Balancer (
alb): route requests from an existing Application Load Balancer listener to a function.
Storage and messaging events
- S3 (
s3): run a function on S3 bucket notifications, such as object uploads, for a new or an existing bucket. - SNS (
sns): subscribe a function to an SNS topic, with filter policies and dead-letter queues. - SQS (
sqs): process messages from an existing SQS queue in batches. - Amazon MQ for ActiveMQ (
activemq): consume messages from an Amazon MQ ActiveMQ broker queue. - Amazon MQ for RabbitMQ (
rabbitmq): consume messages from an Amazon MQ RabbitMQ broker queue.
Stream events
- Kinesis and DynamoDB streams (
stream): process records from a Kinesis data stream or a DynamoDB table stream. - Amazon MSK (
msk): consume records from topics of an Amazon Managed Streaming for Apache Kafka cluster. - Self-managed Apache Kafka (
kafka): consume records from topics of a Kafka cluster you run.
Schedule and event bus events
- Schedule (
schedule): run a function on arateorcronschedule. - EventBridge (
eventBridge): run a function for events on an EventBridge event bus that match a pattern. - CloudWatch Events (
cloudwatchEvent): run a function for AWS service events on the default event bus, such as EC2 state changes. - CloudWatch Logs (
cloudwatchLog): process log events from a CloudWatch Logs log group through a subscription filter.
Other events
- Cognito User Pool (
cognitoUserPool): customize sign-up, sign-in and messages with Cognito User Pool triggers. - CloudFront (
cloudFront): run a function as Lambda@Edge on CloudFront viewer and origin requests and responses. - IoT (
iot): run a function for MQTT messages that match an AWS IoT topic rule. - IoT Fleet Provisioning (
iotFleetProvisioning): validate devices with a pre-provisioning hook of an AWS IoT provisioning template. - Alexa Skill (
alexaSkill): handle requests from an Alexa custom skill. - Alexa Smart Home (
alexaSmartHome): handle directives from an Alexa smart home skill.
Related
- Functions for the rest of a function's configuration
serverless.ymlreference for every event's keys- Invoking Lambda functions in the AWS Lambda developer guide