An AWS Lambda event source mapping reads from streams and poll-based event sources to invoke your functions. You can configure the event source mapping to send invocation records to another service such as Amazon SNS or Amazon SQS when it discards an event batch.
{"Resource":{"MyEventSourceMapping":{"Type":"AWS::Lambda::EventSourceMapping","Properties":{// Required properties"FunctionName":"my-function","EventSourceArn":"arn:aws:dynamodb:us-east-1:111122223333:table/my-table/stream/my-stream","StartingPosition":"LATEST",// Add an OnFailure destination on the event source mapping"DestinationConfig":{"OnFailure":{"Destination":"arn:aws:sqs:us-east-1:111122223333:my-dlq"}}}}}}
1 2 3 4 5 6 7 8 910111213
Resources:MyEventSourceMapping:Type:AWS::Lambda::EventSourceMappingProperties:# Required propertiesFunctionName:my-functionEventSourceArn:arn:aws:dynamodb:us-east-1:111122223333:table/my-table/stream/my-streamStartingPosition:LATEST# Add an OnFailure destination on the event source mappingDestinationConfig:OnFailure:Destination:arn:aws:sqs:us-east-1:111122223333:my-dlq
1 2 3 4 5 6 7 8 910111213141516171819
functions:MyFunction:handler:hello.handlerresources:Resources:MyEventSourceMapping:Type:AWS::Lambda::EventSourceMappingProperties:# Required propertiesFunctionName:Fn::Ref:MyFunctionEventSourceArn:arn:aws:dynamodb:us-east-1:111122223333:table/my-table/stream/my-streamStartingPosition:LATEST# Add an OnFailure destination on the event source mappingDestinationConfig:OnFailure:Destination:arn:aws:sqs:us-east-1:111122223333:my-dlq
1 2 3 4 5 6 7 8 910111213
resource"aws_lambda_event_source_mapping""this"{ # Required fieldsevent_source_arn="arn:aws:dynamodb:us-east-1:111122223333:table/my-table/stream/my-stream"function_name="my-function"starting_position="LATEST" # Add an OnFailure destination on the event source mappingdestination_config{on_failure{destination_arn="arn:aws:sqs:us-east-1:111122223333:my-dlq"}}}