Lift can be installed via: serverless plugin install -n serverless-lift Lift is a Serverless Framework plugin that simplifies deploying pieces of applications via " constructs". To create an SQS queue in serverless.yml, you can either write custom CloudFormation, or you can use Lift. The examples above show how to consume messages from an existing SQS queue. Read the official AWS documentation for more information about IAM Permissions for SQS events. However you can still add additional permissions if you need to. The Serverless Framework will automatically configure the most minimal set of IAM permissions for you. functions: onlyOneOrTwo: handler: handler.preprocess events: - sqs: arn: arn:aws:sqs:region:XXXXXX:myQueue maximumConcurrency: 250 IAM Permissions To turn off maximum concurrency, leave this field empty.įor more details, see the AWS SQS max concurrency documentation. The minimum limit of concurrent functions that the event source can invoke is 2, and the maximum is 1000. The maximum concurrency setting limits the number of concurrent instances of the function that an Amazon SQS event source can invoke. functions: onlyOneOrTwo: handler: handler.preprocess events: - sqs: arn: arn:aws:sqs:region:XXXXXX:myQueue filterPatterns: - a: The following example will only process records where field a is equal to 1 or 2. Note: Serverless only sets this property if you explicitly add it to the sqs configuration (see an example below). If one event matches at least 1 pattern, lambda will process it.įor more details and examples of filter patterns, please see the AWS event filtering documentation It accepts up to 5 filter patterns by default and up to 10 with quota extension. This configuration allows customers to filter event before lambda invocation. functions: compute: handler: pute events: - sqs: arn: arn:aws:sqs:region:XXXXXX:myQueue batchSize: 10 maximumBatchingWindow: 60 functionResponseType: ReportBatchItemFailures Setting filter patterns You can set functionResponseType to ReportBatchItemFailures to let your function return a partial success result if one or more messages in the batch have failed.Ĭheck AWS documentation for more details. The max maximumBatchingWindow is 300 seconds. You can also set maximumBatchingWindow to standard queues to specify the maximum amount of time in seconds to gather records before invoking the function. The max batchSize is 10000 for a standard queue, 10 for a FIFO queue. functions: compute: handler: pute events: # These are all possible formats - sqs: arn:aws:sqs:region:XXXXXX:MyFirstQueue - sqs: arn: Fn::GetAtt: - MySecondQueue - Arn - sqs: arn: Fn::ImportValue: MyExportedQueueArnId - sqs: arn: Fn::Join: - ':' - arn - aws - sqs - Ref: AWS::Region - Ref: AWS::AccountId - MyOtherQueue Setting the BatchSizeįor the SQS event integration, you can set the batchSize, which effects how many SQS messages can be included in a single Lambda invocation. Serverless won't create a new queue for you. Note: The sqs event will hook up your existing SQS Queue to a Lambda function. 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. In the following example, we specify that the compute function should be triggered whenever there are messages in the given SQS Queue.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |