aws-cdk-lib.aws_lambda.EventSourceMappingProps

interface EventSourceMappingProps

LanguageType name
.NETAmazon.CDK.AWS.Lambda.EventSourceMappingProps
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awslambda#EventSourceMappingProps
Javasoftware.amazon.awscdk.services.lambda.EventSourceMappingProps
Pythonaws_cdk.aws_lambda.EventSourceMappingProps
TypeScript (source)aws-cdk-lib » aws_lambda » EventSourceMappingProps

Properties for declaring a new event source mapping.

Example

// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_lambda as lambda } from 'aws-cdk-lib';

declare const eventSourceDlq: lambda.IEventSourceDlq;
declare const filters: any;
declare const function_: lambda.Function;
declare const sourceAccessConfigurationType: lambda.SourceAccessConfigurationType;
const eventSourceMappingProps: lambda.EventSourceMappingProps = {
  target: function_,

  // the properties below are optional
  batchSize: 123,
  bisectBatchOnError: false,
  enabled: false,
  eventSourceArn: 'eventSourceArn',
  filters: [{
    filtersKey: filters,
  }],
  kafkaBootstrapServers: ['kafkaBootstrapServers'],
  kafkaConsumerGroupId: 'kafkaConsumerGroupId',
  kafkaTopic: 'kafkaTopic',
  maxBatchingWindow: cdk.Duration.minutes(30),
  maxConcurrency: 123,
  maxRecordAge: cdk.Duration.minutes(30),
  onFailure: eventSourceDlq,
  parallelizationFactor: 123,
  reportBatchItemFailures: false,
  retryAttempts: 123,
  sourceAccessConfigurations: [{
    type: sourceAccessConfigurationType,
    uri: 'uri',
  }],
  startingPosition: lambda.StartingPosition.TRIM_HORIZON,
  startingPositionTimestamp: 123,
  tumblingWindow: cdk.Duration.minutes(30),
};

Properties

NameTypeDescription
targetIFunctionThe target AWS Lambda function.
batchSize?numberThe largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function.
bisectBatchOnError?booleanIf the function returns an error, split the batch in two and retry.
enabled?booleanSet to false to disable the event source upon creation.
eventSourceArn?stringThe Amazon Resource Name (ARN) of the event source.
filters?{ [string]: any }[]Add filter criteria to Event Source.
kafkaBootstrapServers?string[]A list of host and port pairs that are the addresses of the Kafka brokers in a self managed "bootstrap" Kafka cluster that a Kafka client connects to initially to bootstrap itself.
kafkaConsumerGroupId?stringThe identifier for the Kafka consumer group to join.
kafkaTopic?stringThe name of the Kafka topic.
maxBatchingWindow?DurationThe maximum amount of time to gather records before invoking the function.
maxConcurrency?numberThe maximum concurrency setting limits the number of concurrent instances of the function that an Amazon SQS event source can invoke.
maxRecordAge?DurationThe maximum age of a record that Lambda sends to a function for processing.
onFailure?IEventSourceDlqAn Amazon SQS queue or Amazon SNS topic destination for discarded records.
parallelizationFactor?numberThe number of batches to process from each shard concurrently.
reportBatchItemFailures?booleanAllow functions to return partially successful responses for a batch of records.
retryAttempts?numberThe maximum number of times to retry when the function returns an error.
sourceAccessConfigurations?SourceAccessConfiguration[]Specific settings like the authentication protocol or the VPC components to secure access to your event source.
startingPosition?StartingPositionThe position in the DynamoDB, Kinesis or MSK stream where AWS Lambda should start reading.
startingPositionTimestamp?numberThe time from which to start reading, in Unix time seconds.
tumblingWindow?DurationThe size of the tumbling windows to group records sent to DynamoDB or Kinesis.

target

Type: IFunction

The target AWS Lambda function.


batchSize?

Type: number (optional, default: Amazon Kinesis, Amazon DynamoDB, and Amazon MSK is 100 records. The default for Amazon SQS is 10 messages. For standard SQS queues, the maximum is 10,000. For FIFO SQS queues, the maximum is 10.)

The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function.

Your function receives an event with all the retrieved records.

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


bisectBatchOnError?

Type: boolean (optional, default: false)

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


enabled?

Type: boolean (optional, default: true)

Set to false to disable the event source upon creation.


eventSourceArn?

Type: string (optional, default: not set if using a self managed Kafka cluster, throws an error otherwise)

The Amazon Resource Name (ARN) of the event source.

Any record added to this stream can invoke the Lambda function.


filters?

Type: { [string]: any }[] (optional, default: none)

Add filter criteria to Event Source.

See also: https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html


kafkaBootstrapServers?

Type: string[] (optional, default: none)

A list of host and port pairs that are the addresses of the Kafka brokers in a self managed "bootstrap" Kafka cluster that a Kafka client connects to initially to bootstrap itself.

They are in the format abc.example.com:9096.


kafkaConsumerGroupId?

Type: string (optional, default: none)

The identifier for the Kafka consumer group to join.

The consumer group ID must be unique among all your Kafka event sources. After creating a Kafka event source mapping with the consumer group ID specified, you cannot update this value. The value must have a lenght between 1 and 200 and full the pattern '[a-zA-Z0-9-/:_+=.@-]'. For more information, see Customizable consumer group ID.

See also: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-selfmanagedkafkaeventsourceconfig.html


kafkaTopic?

Type: string (optional, default: no topic)

The name of the Kafka topic.


maxBatchingWindow?

Type: Duration (optional, default: Duration.seconds(0))

The maximum amount of time to gather records before invoking the function.

Maximum of Duration.minutes(5)


maxConcurrency?

Type: number (optional, default: No specific limit.)

The maximum concurrency setting limits the number of concurrent instances of the function that an Amazon SQS event source can invoke.

See also: [https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#events-sqs-max-concurrency

Valid Range: Minimum value of 2. Maximum value of 1000.](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#events-sqs-max-concurrency

Valid Range: Minimum value of 2. Maximum value of 1000.)


maxRecordAge?

Type: Duration (optional, default: infinite or until the record expires.)

The maximum age of a record that Lambda sends to a function for processing.

Valid Range:

  • Minimum value of 60 seconds
  • Maximum value of 7 days

onFailure?

Type: IEventSourceDlq (optional, default: discarded records are ignored)

An Amazon SQS queue or Amazon SNS topic destination for discarded records.


parallelizationFactor?

Type: number (optional, default: 1)

The number of batches to process from each shard concurrently.

Valid Range:

  • Minimum value of 1
  • Maximum value of 10

reportBatchItemFailures?

Type: boolean (optional, default: false)

Allow functions to return partially successful responses for a batch of records.

See also: https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#services-ddb-batchfailurereporting


retryAttempts?

Type: number (optional, default: infinite or until the record expires.)

The maximum number of times to retry when the function returns an error.

Set to undefined if you want lambda to keep retrying infinitely or until the record expires.

Valid Range:

  • Minimum value of 0
  • Maximum value of 10000

sourceAccessConfigurations?

Type: SourceAccessConfiguration[] (optional, default: none)

Specific settings like the authentication protocol or the VPC components to secure access to your event source.

See also: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-sourceaccessconfiguration.html


startingPosition?

Type: StartingPosition (optional, default: no starting position)

The position in the DynamoDB, Kinesis or MSK stream where AWS Lambda should start reading.

See also: https://docs.aws.amazon.com/kinesis/latest/APIReference/API_GetShardIterator.html#Kinesis-GetShardIterator-request-ShardIteratorType


startingPositionTimestamp?

Type: number (optional, default: no timestamp)

The time from which to start reading, in Unix time seconds.


tumblingWindow?

Type: Duration (optional, default: None)

The size of the tumbling windows to group records sent to DynamoDB or Kinesis.

See also: [https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#services-ddb-windows

Valid Range: 0 - 15 minutes](https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#services-ddb-windows

Valid Range: 0 - 15 minutes)