Skip to content
v2.277.0

StreamEventSourceProps Struct ​

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

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';
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
# 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
// 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();
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)
};
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 ​

batchSizeoptionalnumberbatch_sizeoptionalint | floatbatchSizeoptionalNumberBatchSizeoptionaldoubleBatchSizeoptional*float64= 100#
The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function.
notes

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
bisectBatchOnErroroptionalbooleanbisect_batch_on_erroroptionalboolbisectBatchOnErroroptionalBooleanBisectBatchOnErroroptionalboolBisectBatchOnErroroptional*bool= false#
If the function returns an error, split the batch in two and retry.
enabledoptionalbooleanenabledoptionalboolenabledoptionalBooleanEnabledoptionalboolEnabledoptional*bool= true#
If the stream event source mapping should be enabled.
filterEncryptionoptionalIKeyfilter_encryptionoptionalIKeyfilterEncryptionoptionalIKeyFilterEncryptionoptionalIKeyFilterEncryptionoptionalIKey= none#
Add Customer managed KMS key to encrypt Filter Criteria.
filtersoptional{ [key: string]: any }[]filtersoptionaltyping.List[typing.Mapping[str, Any]]filtersoptionalList<Map<String, Object>>FiltersoptionalIDictionary<string, object>[]Filtersoptional*[]*map[string]interface{}= None#
Add filter criteria option.
maxBatchingWindowoptionalDurationmax_batching_windowoptionalDurationmaxBatchingWindowoptionalDurationMaxBatchingWindowoptionalDurationMaxBatchingWindowoptionalDuration#
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).

maxRecordAgeoptionalDurationmax_record_ageoptionalDurationmaxRecordAgeoptionalDurationMaxRecordAgeoptionalDurationMaxRecordAgeoptionalDuration= -1#
The maximum age of a record that Lambda sends to a function for processing.
notes

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.

metricsConfigoptionalMetricsConfigmetrics_configoptionalMetricsConfigmetricsConfigoptionalMetricsConfigMetricsConfigoptionalMetricsConfigMetricsConfigoptionalMetricsConfig#
Configuration for enhanced monitoring metrics collection When specified, enables collection of additional metrics for the stream event source.

Default: Enhanced monitoring is disabled

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

Default: discarded records are ignored

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

Valid Range:

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

reportBatchItemFailuresoptionalbooleanreport_batch_item_failuresoptionalboolreportBatchItemFailuresoptionalBooleanReportBatchItemFailuresoptionalboolReportBatchItemFailuresoptional*bool= false#
Allow functions to return partially successful responses for a batch of records.
retryAttemptsoptionalnumberretry_attemptsoptionalint | floatretryAttemptsoptionalNumberRetryAttemptsoptionaldoubleRetryAttemptsoptional*float64#
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

startingPositionStartingPositionstarting_positionStartingPositionstartingPositionStartingPositionStartingPositionStartingPositionStartingPositionStartingPositionrequired#
Where to begin consuming the stream.
tumblingWindowoptionalDurationtumbling_windowoptionalDurationtumblingWindowoptionalDurationTumblingWindowoptionalDurationTumblingWindowoptionalDuration= None#
The size of the tumbling windows to group records sent to DynamoDB or Kinesis Valid Range: 0 - 15 minutes.