MSK
The object describing an MSK
event source type. For more information, see Using AWS Lambda with Amazon MSK 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
MaximumBatchingWindowInSeconds:
Integer
StartingPosition:String
Stream:String
Topics:List
Properties
-
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
MaximumBatchingWindowInSeconds
property of anAWS::Lambda::EventSourceMapping
resource. -
StartingPosition
-
The position in a stream from which to start reading.
Valid values:
TRIM_HORIZON
orLATEST
Type: String
Required: Yes
AWS CloudFormation compatibility: This property is passed directly to the
StartingPosition
property of anAWS::Lambda::EventSourceMapping
resource. -
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
EventSourceArn
property of anAWS::Lambda::EventSourceMapping
resource. -
Topics
-
The name of the Kafka topic.
Type: List
Required: Yes
AWS CloudFormation compatibility: This property is passed directly to the
Topics
property of anAWS::Lambda::EventSourceMapping
resource.
Examples
Amazon MSK Example for Existing Cluster
The following is an example of an MSK
event source type for an Amazon MSK cluster that already exists in an AWS account.
YAML
Events: MSKEvent: Type: MSK Properties: StartingPosition: LATEST Stream: arn:aws:kafka:us-east-1:012345678012:cluster/exampleClusterName/abcdefab-1234-abcd-5678-cdef0123ab01-2 Topics: - MyTopic
Amazon MSK Example for Cluster Declared in Same Template
The following is an example of an MSK
event source type for an Amazon MSK cluster that is declared in the same template file.
YAML
Events: MSKEvent: Type: MSK Properties: StartingPosition: LATEST Stream: Ref: MyMskCluster # This must be the name of an MSK cluster declared in the same template file Topics: - MyTopic