# EventSourceMappingProps

Properties for declaring a new event source mapping.

Extends: EventSourceMappingProps
Extends: EventSourceMappingOptions
Used as props by: EventSourceMapping

- Source: [`aws-lambda/lib/event-source-mapping.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-lambda/lib/event-source-mapping.ts#L428)

## Example

```ts
// 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_kms as kms } 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 key: kms.Key;
declare const schemaRegistry: lambda.ISchemaRegistry;
declare const sourceAccessConfigurationType: lambda.SourceAccessConfigurationType;
const eventSourceMappingProps: lambda.EventSourceMappingProps = {
  target: function_,

  // the properties below are optional
  batchSize: 123,
  bisectBatchOnError: false,
  enabled: false,
  eventSourceArn: 'eventSourceArn',
  filterEncryption: key,
  filters: [{
    filtersKey: filters,
  }],
  kafkaBootstrapServers: ['kafkaBootstrapServers'],
  kafkaConsumerGroupId: 'kafkaConsumerGroupId',
  kafkaTopic: 'kafkaTopic',
  logLevel: lambda.EventSourceMappingLogLevel.INFO,
  maxBatchingWindow: cdk.Duration.minutes(30),
  maxConcurrency: 123,
  maxRecordAge: cdk.Duration.minutes(30),
  metricsConfig: {
    metrics: [lambda.MetricType.EVENT_COUNT],
  },
  onFailure: eventSourceDlq,
  parallelizationFactor: 123,
  provisionedPollerConfig: {
    maximumPollers: 123,
    minimumPollers: 123,
    pollerGroupName: 'pollerGroupName',
  },
  reportBatchItemFailures: false,
  retryAttempts: 123,
  schemaRegistryConfig: schemaRegistry,
  sourceAccessConfigurations: [{
    type: sourceAccessConfigurationType,
    uri: 'uri',
  }],
  startingPosition: lambda.StartingPosition.TRIM_HORIZON,
  startingPositionTimestamp: 123,
  supportS3OnFailureDestination: false,
  tumblingWindow: cdk.Duration.minutes(30),
};
```

## Properties

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

  **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.

  Your function receives an
  event with all the retrieved records.

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

- `bisectBatchOnError`: boolean = false — If the function returns an error, split the batch in two and retry.

- `enabled`: boolean = true — Set to false to disable the event source upon creation.

- `eventSourceArn`: string — The Amazon Resource Name (ARN) of the event source.

  **Default:** not set if using a self managed Kafka cluster, throws an error otherwise

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

- `filterEncryption`: [IKey](/cdk/api/v2/docs/aws-cdk-lib.aws_kms.IKey.html) = none — Add Customer managed KMS key to encrypt Filter Criteria.

- `filters`: { [key: string]: any }[] = none — Add filter criteria to Event Source.

- `kafkaBootstrapServers`: string[] = 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`: string = 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 length between 1 and 200 and full the pattern '[a-zA-Z0-9-\/*:_+=.@-]*'. For more information, see [Customizable consumer group ID](https://docs.aws.amazon.com/lambda/latest/dg/with-msk.html#services-msk-consumer-group-id).

- `kafkaTopic`: string — The name of the Kafka topic.

  **Default:** no topic

- `logLevel`: [EventSourceMappingLogLevel](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.EventSourceMappingLogLevel.html) — Configuration for logging verbosity from the event source mapping poller.

  **Default:** No logging

  This configuration controls the verbosity of the logs generated by the polling infrastructure
  that reads events from the event source. The logs provide insights into the internal operations
  of the event source mapping, including connection status, polling behavior, and error conditions.

- `maxBatchingWindow`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = Duration.seconds(0) — The maximum amount of time to gather records before invoking the function.

  Maximum of Duration.minutes(5)

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

  **Default:** No specific limit.

- `maxRecordAge`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) — The maximum age of a record that Lambda sends to a function for processing.

  **Default:** infinite or until the record expires.

  Valid Range:
  * Minimum value of 60 seconds
  * Maximum value of 7 days

- `metricsConfig`: [MetricsConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.MetricsConfig.html) — Configuration for enhanced monitoring metrics collection When specified, enables collection of additional metrics for the stream event source.

  **Default:** Enhanced monitoring is disabled

- `onFailure`: [IEventSourceDlq](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.IEventSourceDlq.html) — An Amazon S3, Amazon SQS queue or Amazon SNS topic destination for discarded records.

  **Default:** discarded records are ignored

- `parallelizationFactor`: number = 1 — The number of batches to process from each shard concurrently.

  Valid Range:
  * Minimum value of 1
  * Maximum value of 10

- `provisionedPollerConfig`: [ProvisionedPollerConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.ProvisionedPollerConfig.html) — Configuration for provisioned pollers that read from the event source.

  **Default:** no provisioned pollers

  When specified, allows control over the minimum and maximum number of pollers
  that can be provisioned to process events from the source.

- `reportBatchItemFailures`: boolean = false — Allow functions to return partially successful responses for a batch of records.

- `retryAttempts`: number — The maximum number of times to retry when the function returns an error.

  **Default:** infinite or until the record expires.

  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

- `schemaRegistryConfig`: [ISchemaRegistry](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.ISchemaRegistry.html) = none — Specific configuration settings for a Kafka schema registry.

- `sourceAccessConfigurations`: [SourceAccessConfiguration](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.SourceAccessConfiguration.html)[] = none — Specific settings like the authentication protocol or the VPC components to secure access to your event source.

- `startingPosition`: [StartingPosition](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.StartingPosition.html) — The position in the DynamoDB, Kinesis or MSK stream where AWS Lambda should start reading.

  **Default:** no starting position

- `startingPositionTimestamp`: number — The time from which to start reading, in Unix time seconds.

  **Default:** no timestamp

- `supportS3OnFailureDestination`: boolean = false — Check if support S3 onfailure destination(OFD).

  Kinesis, DynamoDB, MSK and self managed kafka event support S3 OFD

- `target`: [IFunction](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.IFunction.html) (required) — The target AWS Lambda function.

- `tumblingWindow`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = None — The size of the tumbling windows to group records sent to DynamoDB or Kinesis.
