SQS
The object describing an SQS event source type. For more information, see
Using AWS Lambda with Amazon SQS in the AWS Lambda Developer Guide.
SAM generates AWS::Lambda::EventSourceMapping resource when this event type is set
Syntax
To declare this entity in your AWS Serverless Application Model (AWS SAM) template, use the following syntax.
YAML
BatchSize:IntegerEnabled:BooleanFilterCriteria:FilterCriteriaFunctionResponseTypes:ListKmsKeyArn:StringMaximumBatchingWindowInSeconds:IntegerMetricsConfig:MetricsConfigQueue:StringScalingConfig:ScalingConfig
Properties
-
BatchSize -
The maximum number of items to retrieve in a single batch.
Type: Integer
Required: No
Default: 10
AWS CloudFormation compatibility: This property is passed directly to the
BatchSizeproperty of anAWS::Lambda::EventSourceMappingresource.Minimum:
1Maximum:
10000 -
Enabled -
Disables the event source mapping to pause polling and invocation.
Type: Boolean
Required: No
AWS CloudFormation compatibility: This property is passed directly to the
Enabledproperty of anAWS::Lambda::EventSourceMappingresource. -
FilterCriteria -
A object that defines the criteria to determine whether Lambda should process an event. For more information, see AWS Lambda event filtering in the AWS Lambda Developer Guide.
Type: FilterCriteria
Required: No
AWS CloudFormation compatibility: This property is passed directly to the
FilterCriteriaproperty of anAWS::Lambda::EventSourceMappingresource. -
FunctionResponseTypes -
A list of the response types currently applied to the event source mapping. For more information, see Reporting batch item failures in the AWS Lambda Developer Guide.
Valid values:
ReportBatchItemFailuresType: List
Required: No
AWS CloudFormation compatibility: This property is passed directly to the
FunctionResponseTypesproperty of anAWS::Lambda::EventSourceMappingresource. -
KmsKeyArn -
The Amazon Resource Name (ARN) of the key to encrypt information related to this event.
Type: String
Required: No
AWS CloudFormation compatibility: This property is passed directly to the
KmsKeyArnproperty of anAWS::Lambda::EventSourceMappingresource. -
MaximumBatchingWindowInSeconds -
The maximum amount of time, in seconds, to gather records before invoking the function.
Type: Integer
Required: No
AWS CloudFormation compatibility: This property is passed directly to the
MaximumBatchingWindowInSecondsproperty of anAWS::Lambda::EventSourceMappingresource. -
MetricsConfig -
An opt-in configuration to get enhanced metrics for event source mappings that capture each stage of processing. For an example, see MetricsConfig event.
Type: MetricsConfig
Required: No
AWS CloudFormation compatibility: This property is passed directly to the
MetricsConfigproperty of anAWS::Lambda::EventSourceMappingresource. -
Queue -
The ARN of the queue.
Type: String
Required: Yes
AWS CloudFormation compatibility: This property is passed directly to the
EventSourceArnproperty of anAWS::Lambda::EventSourceMappingresource. -
ScalingConfig -
Scaling configuration of SQS pollers to control the invoke rate and set maximum concurrent invokes.
Type:
ScalingConfigRequired: No
AWS CloudFormation compatibility: This property is passed directly to the
ScalingConfigproperty of anAWS::Lambda::EventSourceMappingresource.
Examples
MetricsConfig event
The following is an example of a resource that uses the MetricsConfig property to capture each stage of processing for their event source mappings.
Resources: FilteredEventsFunction: Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/metricsConfig.zip Handler: index.handler Runtime: nodejs16.x Events: KinesisStream: Type: Kinesis Properties: Stream: !GetAtt KinesisStream.Arn StartingPosition: LATEST MetricsConfig: Metrics: - EventCount
Basic SQS event
Events: SQSEvent: Type: SQS Properties: Queue: arn:aws:sqs:us-west-2:012345678901:my-queue BatchSize: 10 Enabled: false FilterCriteria: Filters: - Pattern: '{"key": ["val1", "val2"]}'
Configure partial batch reporting for your SQS queue
Events: SQSEvent: Type: SQS Properties: Enabled: true FunctionResponseTypes: - ReportBatchItemFailures Queue: !GetAtt MySqsQueue.Arn BatchSize: 10
Lambda function with an SQS event that has scaling configured
MyFunction: Type: AWS::Serverless::Function Properties: ... Events: MySQSEvent: Type: SQS Properties: ... ScalingConfig: MaximumConcurrency: 10