Kinesis
The object describing a Kinesis event source type. For more information, see Using AWS Lambda with Amazon Kinesis in the AWS Lambda Developer Guide.
AWS SAM generates an 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:IntegerBisectBatchOnFunctionError:BooleanDestinationConfig:DestinationConfigEnabled:BooleanFilterCriteria:FilterCriteriaFunctionResponseTypes:ListKmsKeyArn:StringMaximumBatchingWindowInSeconds:IntegerMaximumRecordAgeInSeconds:IntegerMaximumRetryAttempts:IntegerMetricsConfig:MetricsConfigParallelizationFactor:IntegerStartingPosition:StringStartingPositionTimestamp:DoubleStream:StringTumblingWindowInSeconds:Integer
Properties
- 
                
BatchSize - 
                
The maximum number of items to retrieve in a single batch.
Type: Integer
Required: No
Default: 100
AWS CloudFormation compatibility: This property is passed directly to the
BatchSizeproperty of anAWS::Lambda::EventSourceMappingresource.Minimum:
1Maximum:
10000 - 
                
BisectBatchOnFunctionError - 
                
If the function returns an error, split the batch in two and retry.
Type: Boolean
Required: No
AWS CloudFormation compatibility: This property is passed directly to the
BisectBatchOnFunctionErrorproperty of anAWS::Lambda::EventSourceMappingresource. - 
                
DestinationConfig - 
                
An Amazon Simple Queue Service (Amazon SQS) queue or Amazon Simple Notification Service (Amazon SNS) topic destination for discarded records.
Type: DestinationConfig
Required: No
AWS CloudFormation compatibility: This property is passed directly to the
DestinationConfigproperty of anAWS::Lambda::EventSourceMappingresource. - 
                
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 to gather records before invoking the function, in seconds.
Type: Integer
Required: No
AWS CloudFormation compatibility: This property is passed directly to the
MaximumBatchingWindowInSecondsproperty of anAWS::Lambda::EventSourceMappingresource. - 
                
MaximumRecordAgeInSeconds - 
                
The maximum age of a record that Lambda sends to a function for processing.
Type: Integer
Required: No
AWS CloudFormation compatibility: This property is passed directly to the
MaximumRecordAgeInSecondsproperty of anAWS::Lambda::EventSourceMappingresource. - 
                
MaximumRetryAttempts - 
                
The maximum number of times to retry when the function returns an error.
Type: Integer
Required: No
AWS CloudFormation compatibility: This property is passed directly to the
MaximumRetryAttemptsproperty 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. - 
                
ParallelizationFactor - 
                
The number of batches to process from each shard concurrently.
Type: Integer
Required: No
AWS CloudFormation compatibility: This property is passed directly to the
ParallelizationFactorproperty of anAWS::Lambda::EventSourceMappingresource. - 
                
StartingPosition - 
                
The position in a stream from which to start reading.
- 
            			
AT_TIMESTAMP– Specify a time from which to start reading records. - 
            			
LATEST– Read only new records. - 
            			
TRIM_HORIZON– Process all available records. 
Valid values:
AT_TIMESTAMP|LATEST|TRIM_HORIZONType: String
Required: Yes
AWS CloudFormation compatibility: This property is passed directly to the
StartingPositionproperty of anAWS::Lambda::EventSourceMappingresource. - 
            			
 - 
    			
StartingPositionTimestamp - 
    			
The time from which to start reading, in Unix time seconds. Define
StartingPositionTimestampwhenStartingPositionis specified asAT_TIMESTAMP.Type: Double
Required: No
AWS CloudFormation compatibility: This property is passed directly to the
StartingPositionTimestampproperty of anAWS::Lambda::EventSourceMappingresource. - 
                
Stream - 
                
The Amazon Resource Name (ARN) of the data stream or a stream consumer.
Type: String
Required: Yes
AWS CloudFormation compatibility: This property is passed directly to the
EventSourceArnproperty of anAWS::Lambda::EventSourceMappingresource. - 
                
TumblingWindowInSeconds - 
                
The duration, in seconds, of a processing window. The valid range is 1 to 900 (15 minutes).
For more information, see Tumbling windows in the AWS Lambda Developer Guide.
Type: Integer
Required: No
AWS CloudFormation compatibility: This property is passed directly to the
TumblingWindowInSecondsproperty 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
Kinesis event source
The following is an example of a Kinesis event source.
YAML
Events: KinesisEvent: Type: Kinesis Properties: Stream: arn:aws:kinesis:us-east-1:123456789012:stream/my-stream StartingPosition: TRIM_HORIZON BatchSize: 10 Enabled: false FilterCriteria: Filters: - Pattern: '{"key": ["val1", "val2"]}'