This is the new AWS CloudFormation Template Reference Guide. Please update your bookmarks and links. For help getting started with CloudFormation, see the AWS CloudFormation User Guide.
AWS::Lambda::EventSourceMapping
The AWS::Lambda::EventSourceMapping resource creates a mapping between an event source and 
      an AWS Lambda function. Lambda reads items from the event source and triggers the function.
For details about each event source type, see the following topics. In particular, each of the topics describes the required and optional parameters for the specific event source.
Syntax
To declare this entity in your AWS CloudFormation template, use the following syntax:
JSON
{ "Type" : "AWS::Lambda::EventSourceMapping", "Properties" : { "AmazonManagedKafkaEventSourceConfig" :AmazonManagedKafkaEventSourceConfig, "BatchSize" :Integer, "BisectBatchOnFunctionError" :Boolean, "DestinationConfig" :DestinationConfig, "DocumentDBEventSourceConfig" :DocumentDBEventSourceConfig, "Enabled" :Boolean, "EventSourceArn" :String, "FilterCriteria" :FilterCriteria, "FunctionName" :String, "FunctionResponseTypes" :[ String, ... ], "KmsKeyArn" :String, "MaximumBatchingWindowInSeconds" :Integer, "MaximumRecordAgeInSeconds" :Integer, "MaximumRetryAttempts" :Integer, "MetricsConfig" :MetricsConfig, "ParallelizationFactor" :Integer, "ProvisionedPollerConfig" :ProvisionedPollerConfig, "Queues" :[ String, ... ], "ScalingConfig" :ScalingConfig, "SelfManagedEventSource" :SelfManagedEventSource, "SelfManagedKafkaEventSourceConfig" :SelfManagedKafkaEventSourceConfig, "SourceAccessConfigurations" :[ SourceAccessConfiguration, ... ], "StartingPosition" :String, "StartingPositionTimestamp" :Number, "Tags" :[ Tag, ... ], "Topics" :[ String, ... ], "TumblingWindowInSeconds" :Integer} }
YAML
Type: AWS::Lambda::EventSourceMapping Properties: AmazonManagedKafkaEventSourceConfig:AmazonManagedKafkaEventSourceConfigBatchSize:IntegerBisectBatchOnFunctionError:BooleanDestinationConfig:DestinationConfigDocumentDBEventSourceConfig:DocumentDBEventSourceConfigEnabled:BooleanEventSourceArn:StringFilterCriteria:FilterCriteriaFunctionName:StringFunctionResponseTypes:- StringKmsKeyArn:StringMaximumBatchingWindowInSeconds:IntegerMaximumRecordAgeInSeconds:IntegerMaximumRetryAttempts:IntegerMetricsConfig:MetricsConfigParallelizationFactor:IntegerProvisionedPollerConfig:ProvisionedPollerConfigQueues:- StringScalingConfig:ScalingConfigSelfManagedEventSource:SelfManagedEventSourceSelfManagedKafkaEventSourceConfig:SelfManagedKafkaEventSourceConfigSourceAccessConfigurations:- SourceAccessConfigurationStartingPosition:StringStartingPositionTimestamp:NumberTags:- TagTopics:- StringTumblingWindowInSeconds:Integer
Properties
- AmazonManagedKafkaEventSourceConfig
- 
                    Specific configuration settings for an Amazon Managed Streaming for Apache Kafka (Amazon MSK) event source. Required: No Type: AmazonManagedKafkaEventSourceConfig Update requires: No interruption 
- BatchSize
- 
                    The maximum number of records in each batch that Lambda pulls from your stream or queue and sends to your function. Lambda passes all of the records in the batch to the function in a single call, up to the payload limit for synchronous invocation (6 MB). - 
                            Amazon Kinesis – Default 100. Max 10,000. 
- 
                            Amazon DynamoDB Streams – Default 100. Max 10,000. 
- 
                            Amazon Simple Queue Service – Default 10. For standard queues the max is 10,000. For FIFO queues the max is 10. 
- 
                            Amazon Managed Streaming for Apache Kafka – Default 100. Max 10,000. 
- 
                            Self-managed Apache Kafka – Default 100. Max 10,000. 
- 
                            Amazon MQ (ActiveMQ and RabbitMQ) – Default 100. Max 10,000. 
- 
                            DocumentDB – Default 100. Max 10,000. 
 Required: No Type: Integer Minimum: 1Maximum: 10000Update requires: No interruption 
- 
                            
- BisectBatchOnFunctionError
- 
                    (Kinesis and DynamoDB Streams only) If the function returns an error, split the batch in two and retry. The default value is false. NoteWhen using BisectBatchOnFunctionError, check theBatchSizeparameter in theOnFailuredestination message's metadata. TheBatchSizecould be greater than 1 since Lambda consolidates failed messages metadata when writing to theOnFailuredestination.Required: No Type: Boolean Update requires: No interruption 
- DestinationConfig
- 
                    (Kinesis, DynamoDB Streams, Amazon MSK, and self-managed Apache Kafka event sources only) A configuration object that specifies the destination of an event after Lambda processes it. Required: No Type: DestinationConfig Update requires: No interruption 
- DocumentDBEventSourceConfig
- 
                    Specific configuration settings for a DocumentDB event source. Required: No Type: DocumentDBEventSourceConfig Update requires: No interruption 
- Enabled
- 
                    When true, the event source mapping is active. When false, Lambda pauses polling and invocation. Default: True Required: No Type: Boolean Update requires: No interruption 
- EventSourceArn
- 
                    The Amazon Resource Name (ARN) of the event source. - 
                            Amazon Kinesis – The ARN of the data stream or a stream consumer. 
- 
                            Amazon DynamoDB Streams – The ARN of the stream. 
- 
                            Amazon Simple Queue Service – The ARN of the queue. 
- 
                            Amazon Managed Streaming for Apache Kafka – The ARN of the cluster or the ARN of the VPC connection (for cross-account event source mappings). 
- 
                            Amazon MQ – The ARN of the broker. 
- 
                            Amazon DocumentDB – The ARN of the DocumentDB change stream. 
 Required: No Type: String Pattern: arn:(aws[a-zA-Z0-9-]*):([a-zA-Z0-9\-])+:((eusc-)?[a-z]{2}((-gov)|(-iso([a-z]?)))?-[a-z]+-\d{1})?:(\d{12})?:(.*)Minimum: 12Maximum: 1024Update requires: Replacement 
- 
                            
- FilterCriteria
- 
                    An object that defines the filter criteria that determine whether Lambda should process an event. For more information, see Lambda event filtering. Required: No Type: FilterCriteria Update requires: No interruption 
- FunctionName
- 
                    The name or ARN of the Lambda function. Name formats- 
                            Function name – MyFunction.
- 
                            Function ARN – arn:aws:lambda:us-west-2:123456789012:function:MyFunction.
- 
                            Version or Alias ARN – arn:aws:lambda:us-west-2:123456789012:function:MyFunction:PROD.
- 
                            Partial ARN – 123456789012:function:MyFunction.
 The length constraint applies only to the full ARN. If you specify only the function name, it's limited to 64 characters in length. Required: Yes Type: String Pattern: (arn:(aws[a-zA-Z-]*)?:lambda:)?((eusc-)?[a-z]{2}((-gov)|(-iso([a-z]?)))?-[a-z]+-\d{1}:)?(\d{12}:)?(function:)?([a-zA-Z0-9-_]+)(:(\$LATEST|[a-zA-Z0-9-_]+))?Minimum: 1Maximum: 140Update requires: No interruption 
- 
                            
- FunctionResponseTypes
- 
                    (Kinesis, DynamoDB Streams, and SQS) A list of current response type enums applied to the event source mapping. Valid Values: ReportBatchItemFailuresRequired: No Type: Array of String Allowed values: ReportBatchItemFailuresUpdate requires: No interruption 
- KmsKeyArn
- 
                    The ARN of the AWS Key Management Service (AWS KMS) customer managed key that Lambda uses to encrypt your function's filter criteria. Required: No Type: String Pattern: (arn:(aws[a-zA-Z-]*)?:[a-z0-9-.]+:.*)|()Minimum: 12Maximum: 2048Update requires: No interruption 
- MaximumBatchingWindowInSeconds
- 
                    The maximum amount of time, in seconds, that Lambda spends gathering records before invoking the function. Default (Kinesis, DynamoDB, Amazon SQS event sources): 0 Default (Amazon MSK, Kafka, Amazon MQ, Amazon DocumentDB event sources): 500 ms Related setting: For Amazon SQS event sources, when you set BatchSizeto a value greater than 10, you must setMaximumBatchingWindowInSecondsto at least 1.Required: No Type: Integer Minimum: 0Maximum: 300Update requires: No interruption 
- MaximumRecordAgeInSeconds
- 
                    (Kinesis and DynamoDB Streams only) Discard records older than the specified age. The default value is -1, which sets the maximum age to infinite. When the value is set to infinite, Lambda never discards old records. NoteThe minimum valid value for maximum record age is 60s. Although values less than 60 and greater than -1 fall within the parameter's absolute range, they are not allowed Required: No Type: Integer Minimum: -1Maximum: 604800Update requires: No interruption 
- MaximumRetryAttempts
- 
                    (Kinesis and DynamoDB Streams only) Discard records after the specified number of retries. The default value is -1, which sets the maximum number of retries to infinite. When MaximumRetryAttempts is infinite, Lambda retries failed records until the record expires in the event source. Required: No Type: Integer Minimum: -1Maximum: 10000Update requires: No interruption 
- MetricsConfig
- 
                    The metrics configuration for your event source. For more information, see Event source mapping metrics. Required: No Type: MetricsConfig Update requires: No interruption 
- ParallelizationFactor
- 
                    (Kinesis and DynamoDB Streams only) The number of batches to process concurrently from each shard. The default value is 1. Required: No Type: Integer Minimum: 1Maximum: 10Update requires: No interruption 
- ProvisionedPollerConfig
- 
                    (Amazon MSK and self-managed Apache Kafka only) The provisioned mode configuration for the event source. For more information, see provisioned mode. Required: No Type: ProvisionedPollerConfig Update requires: No interruption 
- Queues
- 
                    (Amazon MQ) The name of the Amazon MQ broker destination queue to consume. Required: No Type: Array of String Minimum: 1 | 1Maximum: 1000 | 1Update requires: No interruption 
- ScalingConfig
- 
                    (Amazon SQS only) The scaling configuration for the event source. For more information, see Configuring maximum concurrency for Amazon SQS event sources. Required: No Type: ScalingConfig Update requires: No interruption 
- SelfManagedEventSource
- 
                    The self-managed Apache Kafka cluster for your event source. Required: No Type: SelfManagedEventSource Update requires: Replacement 
- SelfManagedKafkaEventSourceConfig
- 
                    Specific configuration settings for a self-managed Apache Kafka event source. Required: No Type: SelfManagedKafkaEventSourceConfig Update requires: No interruption 
- SourceAccessConfigurations
- 
                    An array of the authentication protocol, VPC components, or virtual host to secure and define your event source. Required: No Type: Array of SourceAccessConfiguration Minimum: 1Maximum: 22Update requires: No interruption 
- StartingPosition
- 
                    The position in a stream from which to start reading. Required for Amazon Kinesis and Amazon DynamoDB. - 
                            LATEST - Read only new records. 
- 
                            TRIM_HORIZON - Process all available records. 
- 
                            AT_TIMESTAMP - Specify a time from which to start reading records. 
 Required: No Type: String Pattern: (LATEST|TRIM_HORIZON|AT_TIMESTAMP)+Minimum: 6Maximum: 12Update requires: Replacement 
- 
                            
- StartingPositionTimestamp
- 
                    With StartingPositionset toAT_TIMESTAMP, the time from which to start reading, in Unix time seconds.StartingPositionTimestampcannot be in the future.Required: No Type: Number Update requires: Replacement 
- 
                    A list of tags to add to the event source mapping. NoteYou must have the lambda:TagResource,lambda:UntagResource, andlambda:ListTagspermissions for your IAM principal to manage the AWS CloudFormation stack. If you don't have these permissions, there might be unexpected behavior with stack-level tags propagating to the resource during resource creation and update.Required: No Type: Array of Tag Update requires: No interruption 
- Topics
- 
                    The name of the Kafka topic. Required: No Type: Array of String Minimum: 1 | 1Maximum: 249 | 1Update requires: No interruption 
- TumblingWindowInSeconds
- 
                    (Kinesis and DynamoDB Streams only) The duration in seconds of a processing window for DynamoDB and Kinesis Streams event sources. A value of 0 seconds indicates no tumbling window. Required: No Type: Integer Minimum: 0Maximum: 900Update requires: No interruption 
Return values
Ref
When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the mapping's ID.
For more information about using the Ref function, see Ref.
Fn::GetAtt
The Fn::GetAtt intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.
For more information about using the Fn::GetAtt intrinsic function, see Fn::GetAtt.
- EventSourceMappingArn
- 
                            The Amazon Resource Name (ARN) of the event source mapping. 
- Id
- 
                            The event source mapping's ID. 
Examples
Event Source Mapping
Create an event source mapping that reads events from Amazon Kinesis and invokes a Lambda function in the same template.
JSON
"EventSourceMapping": { "Type": "AWS::Lambda::EventSourceMapping", "Properties": { "EventSourceArn": { "Fn::Join": [ "", [ "arn:aws:kinesis:", { "Ref": "AWS::Region" }, ":", { "Ref": "AWS::AccountId" }, ":stream/", { "Ref": "KinesisStream" } ] ] }, "FunctionName": { "Fn::GetAtt": [ "LambdaFunction", "Arn" ] }, "StartingPosition": "TRIM_HORIZON" } }
YAML
MyEventSourceMapping: Type: AWS::Lambda::EventSourceMapping Properties: EventSourceArn: Fn::Join: - "" - - "arn:aws:kinesis:" - Ref: "AWS::Region" - ":" - Ref: "AWS::AccountId" - ":stream/" - Ref: "KinesisStream" FunctionName: Fn::GetAtt: - "LambdaFunction" - "Arn" StartingPosition: "TRIM_HORIZON"