View a markdown version of this page

CreateEventSourceMapping - AWS Lambda

CreateEventSourceMapping

Creates a mapping between an event source and an AWS Lambda function. Lambda reads items from the event source and invokes the function.

For details about how to configure different event sources, see the following topics.

The following error handling options are available for stream sources (DynamoDB, Kinesis, Amazon MSK, and self-managed Apache Kafka):

  • BisectBatchOnFunctionError – If the function returns an error, split the batch in two and retry.

  • MaximumRecordAgeInSeconds – Discard records older than the specified age. The default value is infinite (-1). When set to infinite (-1), failed records are retried until the record expires

  • MaximumRetryAttempts – Discard records after the specified number of retries. The default value is infinite (-1). When set to infinite (-1), failed records are retried until the record expires.

  • OnFailure – Send discarded records to an Amazon SQS queue, Amazon SNS topic, Kafka topic, or Amazon S3 bucket. For more information, see Adding a destination.

The following option is available only for DynamoDB and Kinesis event sources:

  • ParallelizationFactor – Process multiple batches from each shard concurrently.

For information about which configuration parameters apply to each event source, see the following topics.

Request Syntax

POST /2015-03-31/event-source-mappings HTTP/1.1 Content-type: application/json { "AmazonManagedKafkaEventSourceConfig": { "ConsumerGroupId": "string", "SchemaRegistryConfig": { "AccessConfigs": [ { "Type": "string", "URI": "string" } ], "EventRecordFormat": "string", "SchemaRegistryURI": "string", "SchemaValidationConfigs": [ { "Attribute": "string" } ] } }, "BatchSize": number, "BisectBatchOnFunctionError": boolean, "DestinationConfig": { "OnFailure": { "Destination": "string" }, "OnSuccess": { "Destination": "string" } }, "DocumentDBEventSourceConfig": { "CollectionName": "string", "DatabaseName": "string", "FullDocument": "string" }, "Enabled": boolean, "EventSourceArn": "string", "FilterCriteria": { "Filters": [ { "Pattern": "string" } ] }, "FunctionName": "string", "FunctionResponseTypes": [ "string" ], "KMSKeyArn": "string", "LoggingConfig": { "SystemLogLevel": "string" }, "MaximumBatchingWindowInSeconds": number, "MaximumRecordAgeInSeconds": number, "MaximumRetryAttempts": number, "MetricsConfig": { "Metrics": [ "string" ] }, "ParallelizationFactor": number, "ProvisionedPollerConfig": { "MaximumPollers": number, "MinimumPollers": number, "PollerGroupName": "string" }, "Queues": [ "string" ], "ScalingConfig": { "MaximumConcurrency": number }, "SelfManagedEventSource": { "Endpoints": { "string" : [ "string" ] } }, "SelfManagedKafkaEventSourceConfig": { "ConsumerGroupId": "string", "SchemaRegistryConfig": { "AccessConfigs": [ { "Type": "string", "URI": "string" } ], "EventRecordFormat": "string", "SchemaRegistryURI": "string", "SchemaValidationConfigs": [ { "Attribute": "string" } ] } }, "SourceAccessConfigurations": [ { "Type": "string", "URI": "string" } ], "StartingPosition": "string", "StartingPositionTimestamp": number, "Tags": { "string" : "string" }, "Topics": [ "string" ], "TumblingWindowInSeconds": number }

URI Request Parameters

The request does not use any URI parameters.

Request Body

The request accepts the following data in JSON format.

AmazonManagedKafkaEventSourceConfig

Specific configuration settings for an Amazon Managed Streaming for Apache Kafka (Amazon MSK) event source.

Type: AmazonManagedKafkaEventSourceConfig object

Required: No

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.

Type: Integer

Valid Range: Minimum value of 1. Maximum value of 10000.

Required: No

BisectBatchOnFunctionError

(Kinesis, DynamoDB Streams, Amazon MSK, and self-managed Apache Kafka) If the function returns an error, split the batch in two and retry.

Type: Boolean

Required: No

DestinationConfig

(Kinesis, DynamoDB Streams, Amazon MSK, and self-managed Apache Kafka) A configuration object that specifies the destination of an event after Lambda processes it.

Type: DestinationConfig object

Required: No

DocumentDBEventSourceConfig

Specific configuration settings for a DocumentDB event source.

Type: DocumentDBEventSourceConfig object

Required: No

Enabled

When true, the event source mapping is active. When false, Lambda pauses polling and invocation.

Default: True

Type: Boolean

Required: No

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.

Type: String

Pattern: arn:(aws[a-zA-Z0-9-]*):([a-zA-Z0-9\-])+:([a-z]