In the following example, we specify that the compute
function should be triggered whenever there are messages in the given SQS Queue.
The ARN for the queue can be specified as a string, the reference to the ARN of a resource by logical ID, or the import of an ARN that was exported by a different service or CloudFormation stack.
Note: The sqs
event will hook up your existing SQS Queue to a Lambda function. Serverless won't create a new queue for you.
IMPORTANT: AWS is not supporting FIFO queue to trigger Lambda function so your queue(s) must be a standard queue.
functions:
compute:
handler: handler.compute
events:
- sqs: arn:aws:sqs:region:XXXXXX:MyFirstQueue
- sqs:
arn:
Fn::GetAtt:
- MySecondQueue
- Arn
- sqs:
arn:
Fn::ImportValue: MyExportedQueueArnId
For the SQS event integration, you can set the batchSize
, which effects how many SQS messages will be included in a single Lambda invocation. The default batchSize
is 10, and the max batchSize
is 10.
functions:
preprocess:
handler: handler.preprocess
events:
- sqs:
arn: arn:aws:sqs:region:XXXXXX:myQueue
batchSize: 10
developers
Made with love in San Francisco + Atlanta, Austria, Germany, Pakistan, Poland, Nebraska & Thailand
Serverless, Inc. © 2018