# StreamEventSourceProps

The set of properties for streaming event sources shared by Dynamo and Kinesis.

Extends: [BaseStreamEventSourceProps](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda_event_sources.BaseStreamEventSourceProps.html)
Used as props by: [StreamEventSource](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda_event_sources.StreamEventSource.html)

- Source: [`aws-lambda-event-sources/lib/stream.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/aws-lambda-event-sources/lib/stream.ts#L96)
- Type last changed: v2.188.0 · 4 Apr 2025

## Example

TypeScript:

```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';
import { aws_lambda_event_sources as lambda_event_sources } from 'aws-cdk-lib';

declare const eventSourceDlq: lambda.IEventSourceDlq;
declare const filters: any;
declare const key: kms.Key;
const streamEventSourceProps: lambda_event_sources.StreamEventSourceProps = {
  startingPosition: lambda.StartingPosition.TRIM_HORIZON,

  // the properties below are optional
  batchSize: 123,
  bisectBatchOnError: false,
  enabled: false,
  filterEncryption: key,
  filters: [{
    filtersKey: filters,
  }],
  maxBatchingWindow: cdk.Duration.minutes(30),
  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,
  tumblingWindow: cdk.Duration.minutes(30),
};
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
from aws_cdk import aws_kms as kms
from aws_cdk import aws_lambda as lambda_
from aws_cdk import aws_lambda_event_sources as lambda_event_sources

# event_source_dlq: lambda.IEventSourceDlq
# filters: Any
# key: kms.Key

stream_event_source_props = lambda_event_sources.StreamEventSourceProps(
    starting_position=lambda_.StartingPosition.TRIM_HORIZON,

    # the properties below are optional
    batch_size=123,
    bisect_batch_on_error=False,
    enabled=False,
    filter_encryption=key,
    filters=[{
        "filters_key": filters
    }],
    max_batching_window=cdk.Duration.minutes(30),
    max_record_age=cdk.Duration.minutes(30),
    metrics_config=lambda.MetricsConfig(
        metrics=[lambda_.MetricType.EVENT_COUNT]
    ),
    on_failure=event_source_dlq,
    parallelization_factor=123,
    provisioned_poller_config=lambda_event_sources.ProvisionedPollerConfig(
        maximum_pollers=123,
        minimum_pollers=123,
        poller_group_name="pollerGroupName"
    ),
    report_batch_item_failures=False,
    retry_attempts=123,
    tumbling_window=cdk.Duration.minutes(30)
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.kms.*;
import software.amazon.awscdk.services.lambda.*;
import software.amazon.awscdk.services.lambda.eventsources.*;

IEventSourceDlq eventSourceDlq;
Object filters;
Key key;

StreamEventSourceProps streamEventSourceProps = StreamEventSourceProps.builder()
        .startingPosition(StartingPosition.TRIM_HORIZON)

        // the properties below are optional
        .batchSize(123)
        .bisectBatchOnError(false)
        .enabled(false)
        .filterEncryption(key)
        .filters(List.of(Map.of(
                "filtersKey", filters)))
        .maxBatchingWindow(Duration.minutes(30))
        .maxRecordAge(Duration.minutes(30))
        .metricsConfig(MetricsConfig.builder()
                .metrics(List.of(MetricType.EVENT_COUNT))
                .build())
        .onFailure(eventSourceDlq)
        .parallelizationFactor(123)
        .provisionedPollerConfig(ProvisionedPollerConfig.builder()
                .maximumPollers(123)
                .minimumPollers(123)
                .pollerGroupName("pollerGroupName")
                .build())
        .reportBatchItemFailures(false)
        .retryAttempts(123)
        .tumblingWindow(Duration.minutes(30))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;
using Amazon.CDK.AWS.KMS;
using Amazon.CDK.AWS.Lambda;
using Amazon.CDK.AWS.Lambda.EventSources;

IEventSourceDlq eventSourceDlq;
var filters;
Key key;

var streamEventSourceProps = new StreamEventSourceProps {
    StartingPosition = StartingPosition.TRIM_HORIZON,

    // the properties below are optional
    BatchSize = 123,
    BisectBatchOnError = false,
    Enabled = false,
    FilterEncryption = key,
    Filters = new [] { new Dictionary<string, object> {
        { "filtersKey", filters }
    } },
    MaxBatchingWindow = Duration.Minutes(30),
    MaxRecordAge = Duration.Minutes(30),
    MetricsConfig = new MetricsConfig {
        Metrics = new [] { MetricType.EVENT_COUNT }
    },
    OnFailure = eventSourceDlq,
    ParallelizationFactor = 123,
    ProvisionedPollerConfig = new ProvisionedPollerConfig {
        MaximumPollers = 123,
        MinimumPollers = 123,
        PollerGroupName = "pollerGroupName"
    },
    ReportBatchItemFailures = false,
    RetryAttempts = 123,
    TumblingWindow = Duration.Minutes(30)
};
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var eventSourceDlq IEventSourceDlq
var filters interface{}
var key Key

streamEventSourceProps := &StreamEventSourceProps{
	StartingPosition: awscdk.Aws_lambda.StartingPosition_TRIM_HORIZON,

	// the properties below are optional
	BatchSize: jsii.Number(123),
	BisectBatchOnError: jsii.Boolean(false),
	Enabled: jsii.Boolean(false),
	FilterEncryption: key,
	Filters: []map[string]interface{}{
		map[string]interface{}{
			"filtersKey": filters,
		},
	},
	MaxBatchingWindow: cdk.Duration_Minutes(jsii.Number(30)),
	MaxRecordAge: cdk.Duration_*Minutes(jsii.Number(30)),
	MetricsConfig: &MetricsConfig{
		Metrics: []MetricType{
			awscdk.*Aws_lambda.MetricType_EVENT_COUNT,
		},
	},
	OnFailure: eventSourceDlq,
	ParallelizationFactor: jsii.Number(123),
	ProvisionedPollerConfig: &ProvisionedPollerConfig{
		MaximumPollers: jsii.Number(123),
		MinimumPollers: jsii.Number(123),
		PollerGroupName: jsii.String("pollerGroupName"),
	},
	ReportBatchItemFailures: jsii.Boolean(false),
	RetryAttempts: jsii.Number(123),
	TumblingWindow: cdk.Duration_*Minutes(jsii.Number(30)),
}
```

## Properties

- `batchSize`: number = 100 — 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:
    * 1000 for `DynamoEventSource`
    * 10000 for `KinesisEventSource`, `ManagedKafkaEventSource` and `SelfManagedKafkaEventSource`

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

- `enabled`: boolean = true — If the stream event source mapping should be enabled.

- `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 option.

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

  **Default:** Duration.seconds(0) for Kinesis, DynamoDB, and SQS event sources, Duration.millis(500) for MSK, self-managed Kafka, and Amazon MQ.

  Maximum of Duration.minutes(5).

- `maxRecordAge`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = -1 — 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

  The default value is -1, which sets the maximum age to infinite.
  When the value is set to infinite, Lambda never discards old records.
  Record are valid until it expires in the event source.

- `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_event_sources.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 — Maximum number of retry attempts.

  **Default:** -1 (infinite retries)

  Set to -1 for infinite retries (until the record expires in the event source).

  Valid Range: -1 (infinite) or 0 to 10000

- `startingPosition`: [StartingPosition](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.StartingPosition.html) (required) — Where to begin consuming the stream.

- `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 Valid Range: 0 - 15 minutes.
