Skip to content
v2.274.0

EventSourceMappingOptions Struct ​

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 key: kms.Key;
declare const schemaRegistry: lambda.ISchemaRegistry;
declare const sourceAccessConfigurationType: lambda.SourceAccessConfigurationType;
const eventSourceMappingOptions: lambda.EventSourceMappingOptions = {
  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 ​

batchSizenumberbatch_sizeint | floatbatchSizeNumberBatchSizedoubleBatchSize*float64#
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.

bisectBatchOnErrorbooleanbisect_batch_on_errorboolbisectBatchOnErrorBooleanBisectBatchOnErrorboolBisectBatchOnError*bool= false#
If the function returns an error, split the batch in two and retry.
enabledbooleanenabledboolenabledBooleanEnabledboolEnabled*bool= true#
Set to false to disable the event source upon creation.
eventSourceArnstringevent_source_arnstreventSourceArnStringEventSourceArnstringEventSourceArn*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.

filterEncryptionIKeyfilter_encryptionIKeyfilterEncryptionIKeyFilterEncryptionIKeyFilterEncryptionIKey= none#
Add Customer managed KMS key to encrypt Filter Criteria.
filters{ [key: string]: any }[]filterstyping.List[typing.Mapping[str, Any]]filtersList<Map<String, Object>>FiltersIDictionary<string, object>[]Filters*[]*map[string]interface{}= none#
Add filter criteria to Event Source.
kafkaBootstrapServersstring[]kafka_bootstrap_serverstyping.List[str]kafkaBootstrapServersList<String>KafkaBootstrapServersstring[]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.

kafkaConsumerGroupIdstringkafka_consumer_group_idstrkafkaConsumerGroupIdStringKafkaConsumerGroupIdstringKafkaConsumerGroupId*string= none#
The identifier for the Kafka consumer group to join.
notes

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.

kafkaTopicstringkafka_topicstrkafkaTopicStringKafkaTopicstringKafkaTopic*string#
The name of the Kafka topic.

Default: no topic

Configuration for logging verbosity from the event source mapping poller.

Default: No logging

notes

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.

maxBatchingWindowDurationmax_batching_windowDurationmaxBatchingWindowDurationMaxBatchingWindowDurationMaxBatchingWindowDuration= Duration.seconds(0)#
The maximum amount of time to gather records before invoking the function.

Maximum of Duration.minutes(5)

maxConcurrencynumbermax_concurrencyint | floatmaxConcurrencyNumberMaxConcurrencydoubleMaxConcurrency*float64#
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.

maxRecordAgeDurationmax_record_ageDurationmaxRecordAgeDurationMaxRecordAgeDurationMaxRecordAgeDuration#
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
metricsConfigMetricsConfigmetrics_configMetricsConfigmetricsConfigMetricsConfigMetricsConfigMetricsConfigMetricsConfigMetricsConfig#
Configuration for enhanced monitoring metrics collection When specified, enables collection of additional metrics for the stream event source.

Default: Enhanced monitoring is disabled

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

Default: discarded records are ignored

parallelizationFactornumberparallelization_factorint | floatparallelizationFactorNumberParallelizationFactordoubleParallelizationFactor*float64= 1#
The number of batches to process from each shard concurrently.

Valid Range:

  • Minimum value of 1
  • Maximum value of 10
provisionedPollerConfigProvisionedPollerConfigprovisioned_poller_configProvisionedPollerConfigprovisionedPollerConfigProvisionedPollerConfigProvisionedPollerConfigProvisionedPollerConfigProvisionedPollerConfigProvisionedPollerConfig#
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.

reportBatchItemFailuresbooleanreport_batch_item_failuresboolreportBatchItemFailuresBooleanReportBatchItemFailuresboolReportBatchItemFailures*bool= false#
Allow functions to return partially successful responses for a batch of records.
retryAttemptsnumberretry_attemptsint | floatretryAttemptsNumberRetryAttemptsdoubleRetryAttempts*float64#
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
schemaRegistryConfigISchemaRegistryschema_registry_configISchemaRegistryschemaRegistryConfigISchemaRegistrySchemaRegistryConfigISchemaRegistrySchemaRegistryConfigISchemaRegistry= none#
Specific configuration settings for a Kafka schema registry.
sourceAccessConfigurationsSourceAccessConfiguration[]source_access_configurationstyping.List[SourceAccessConfiguration]sourceAccessConfigurationsList<SourceAccessConfiguration>SourceAccessConfigurationsSourceAccessConfiguration[]SourceAccessConfigurations*[]SourceAccessConfiguration= none#
Specific settings like the authentication protocol or the VPC components to secure access to your event source.
startingPositionStartingPositionstarting_positionStartingPositionstartingPositionStartingPositionStartingPositionStartingPositionStartingPositionStartingPosition#
The position in the DynamoDB, Kinesis or MSK stream where AWS Lambda should start reading.

Default: no starting position

startingPositionTimestampnumberstarting_position_timestampint | floatstartingPositionTimestampNumberStartingPositionTimestampdoubleStartingPositionTimestamp*float64#
The time from which to start reading, in Unix time seconds.

Default: no timestamp

supportS3OnFailureDestinationbooleansupport_s3_on_failure_destinationboolsupportS3OnFailureDestinationBooleanSupportS3OnFailureDestinationboolSupportS3OnFailureDestination*bool= false#
Check if support S3 onfailure destination(OFD).

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

tumblingWindowDurationtumbling_windowDurationtumblingWindowDurationTumblingWindowDurationTumblingWindowDuration= None#
The size of the tumbling windows to group records sent to DynamoDB or Kinesis.