From 00a78e0679f839bdcd955c83f7e873f24c96bf82 Mon Sep 17 00:00:00 2001 From: zehsor Date: Sat, 11 Dec 2021 08:34:02 +0100 Subject: [PATCH 1/3] fix(aws-lambda-event-sources): unsupported properties for SelfManagedKafkaEventSource and ManagedKafkaEventSource --- .../aws-lambda-event-sources/lib/kafka.ts | 5 +- .../aws-lambda-event-sources/lib/stream.ts | 61 +++++++++++-------- 2 files changed, 38 insertions(+), 28 deletions(-) diff --git a/packages/@aws-cdk/aws-lambda-event-sources/lib/kafka.ts b/packages/@aws-cdk/aws-lambda-event-sources/lib/kafka.ts index e31fac89100cb..b6060b4f91a00 100644 --- a/packages/@aws-cdk/aws-lambda-event-sources/lib/kafka.ts +++ b/packages/@aws-cdk/aws-lambda-event-sources/lib/kafka.ts @@ -4,7 +4,7 @@ import * as iam from '@aws-cdk/aws-iam'; import * as lambda from '@aws-cdk/aws-lambda'; import * as secretsmanager from '@aws-cdk/aws-secretsmanager'; import { Stack, Names } from '@aws-cdk/core'; -import { StreamEventSource, StreamEventSourceProps } from './stream'; +import { StreamEventSource, BaseStreamEventSourceProps } from './stream'; // keep this import separate from other imports to reduce chance for merge conflicts with v2-main // eslint-disable-next-line no-duplicate-imports, import/order @@ -13,7 +13,8 @@ import { Construct } from '@aws-cdk/core'; /** * Properties for a Kafka event source */ -export interface KafkaEventSourceProps extends StreamEventSourceProps { +export interface KafkaEventSourceProps extends BaseStreamEventSourceProps{ + /** * The Kafka topic to subscribe to */ diff --git a/packages/@aws-cdk/aws-lambda-event-sources/lib/stream.ts b/packages/@aws-cdk/aws-lambda-event-sources/lib/stream.ts index 01288efb21a6c..ccaf85b68f787 100644 --- a/packages/@aws-cdk/aws-lambda-event-sources/lib/stream.ts +++ b/packages/@aws-cdk/aws-lambda-event-sources/lib/stream.ts @@ -5,7 +5,7 @@ import { Duration } from '@aws-cdk/core'; * The set of properties for event sources that follow the streaming model, * such as, Dynamo, Kinesis and Kafka. */ -export interface StreamEventSourceProps { +export interface BaseStreamEventSourceProps{ /** * 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 @@ -15,25 +15,50 @@ export interface StreamEventSourceProps { * * Minimum value of 1 * * Maximum value of: * * 1000 for {@link DynamoEventSource} - * * 10000 for {@link KinesisEventSource} + * * 10000 for {@link KinesisEventSource}, {@link ManagedKafkaEventSource} and {@link SelfManagedKafkaEventSource} * * @default 100 */ readonly batchSize?: number; /** - * If the function returns an error, split the batch in two and retry. + * An Amazon SQS queue or Amazon SNS topic destination for discarded records. * - * @default false + * @default discarded records are ignored */ - readonly bisectBatchOnError?: boolean; + readonly onFailure?: lambda.IEventSourceDlq; /** - * An Amazon SQS queue or Amazon SNS topic destination for discarded records. + * Where to begin consuming the stream. + */ + readonly startingPosition: lambda.StartingPosition; + + /** + * The maximum amount of time to gather records before invoking the function. + * Maximum of Duration.minutes(5) * - * @default discarded records are ignored + * @default Duration.seconds(0) */ - readonly onFailure?: lambda.IEventSourceDlq; + readonly maxBatchingWindow?: Duration; + + /** + * If the stream event source mapping should be enabled. + * + * @default true + */ + readonly enabled?: boolean; +} +/** + * The set of properties for event sources that follow the streaming model, + * such as, Dynamo, Kinesis. + */ +export interface StreamEventSourceProps extends BaseStreamEventSourceProps { + /** + * If the function returns an error, split the batch in two and retry. + * + * @default false + */ + readonly bisectBatchOnError?: boolean; /** * The maximum age of a record that Lambda sends to a function for processing. @@ -45,6 +70,7 @@ export interface StreamEventSourceProps { */ readonly maxRecordAge?: Duration; + /** * Maximum number of retry attempts * Valid Range: @@ -55,6 +81,7 @@ export interface StreamEventSourceProps { */ readonly retryAttempts?: number; + /** * The number of batches to process from each shard concurrently. * Valid Range: @@ -65,10 +92,6 @@ export interface StreamEventSourceProps { */ readonly parallelizationFactor?: number; - /** - * Where to begin consuming the stream. - */ - readonly startingPosition: lambda.StartingPosition; /** * Allow functions to return partially successful responses for a batch of records. @@ -79,13 +102,6 @@ export interface StreamEventSourceProps { */ readonly reportBatchItemFailures?: boolean; - /** - * The maximum amount of time to gather records before invoking the function. - * Maximum of Duration.minutes(5) - * - * @default Duration.seconds(0) - */ - readonly maxBatchingWindow?: Duration; /** * The size of the tumbling windows to group records sent to DynamoDB or Kinesis @@ -94,13 +110,6 @@ export interface StreamEventSourceProps { * @default - None */ readonly tumblingWindow?: Duration; - - /** - * If the stream event source mapping should be enabled. - * - * @default true - */ - readonly enabled?: boolean; } /** From 4e6736b9742ad266f0dfbffc51e462bbd810c934 Mon Sep 17 00:00:00 2001 From: zehsor Date: Sat, 11 Dec 2021 14:26:34 +0100 Subject: [PATCH 2/3] chore(aws-lambda-event-sources): update allowed-breaking-changes.txt --- allowed-breaking-changes.txt | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/allowed-breaking-changes.txt b/allowed-breaking-changes.txt index fa3498335f679..56b1145d61b39 100644 --- a/allowed-breaking-changes.txt +++ b/allowed-breaking-changes.txt @@ -93,3 +93,26 @@ incompatible-argument:@aws-cdk/aws-autoscaling-hooktargets.FunctionHook.bind incompatible-argument:@aws-cdk/aws-autoscaling-hooktargets.QueueHook.bind incompatible-argument:@aws-cdk/aws-autoscaling-hooktargets.TopicHook.bind incompatible-argument:@aws-cdk/aws-autoscaling.ILifecycleHookTarget.bind + +# removed properties from kafka eventsources as they are not supported +removed:@aws-cdk/aws-lambda-event-sources.KafkaEventSourceProps.bisectBatchOnError +removed:@aws-cdk/aws-lambda-event-sources.KafkaEventSourceProps.maxRecordAge +removed:@aws-cdk/aws-lambda-event-sources.KafkaEventSourceProps.parallelizationFactor +removed:@aws-cdk/aws-lambda-event-sources.KafkaEventSourceProps.reportBatchItemFailures +removed:@aws-cdk/aws-lambda-event-sources.KafkaEventSourceProps.retryAttempts +removed:@aws-cdk/aws-lambda-event-sources.KafkaEventSourceProps.tumblingWindow +removed:@aws-cdk/aws-lambda-event-sources.ManagedKafkaEventSourceProps.bisectBatchOnError +removed:@aws-cdk/aws-lambda-event-sources.ManagedKafkaEventSourceProps.maxRecordAge +removed:@aws-cdk/aws-lambda-event-sources.ManagedKafkaEventSourceProps.parallelizationFactor +removed:@aws-cdk/aws-lambda-event-sources.ManagedKafkaEventSourceProps.reportBatchItemFailures +removed:@aws-cdk/aws-lambda-event-sources.ManagedKafkaEventSourceProps.retryAttempts +removed:@aws-cdk/aws-lambda-event-sources.ManagedKafkaEventSourceProps.tumblingWindow +removed:@aws-cdk/aws-lambda-event-sources.SelfManagedKafkaEventSourceProps.bisectBatchOnError +removed:@aws-cdk/aws-lambda-event-sources.SelfManagedKafkaEventSourceProps.maxRecordAge +removed:@aws-cdk/aws-lambda-event-sources.SelfManagedKafkaEventSourceProps.parallelizationFactor +removed:@aws-cdk/aws-lambda-event-sources.SelfManagedKafkaEventSourceProps.reportBatchItemFailures +removed:@aws-cdk/aws-lambda-event-sources.SelfManagedKafkaEventSourceProps.retryAttempts +removed:@aws-cdk/aws-lambda-event-sources.SelfManagedKafkaEventSourceProps.tumblingWindow +base-types:@aws-cdk/aws-lambda-event-sources.KafkaEventSourceProps +base-types:@aws-cdk/aws-lambda-event-sources.ManagedKafkaEventSourceProps +base-types:@aws-cdk/aws-lambda-event-sources.SelfManagedKafkaEventSourceProps \ No newline at end of file From 0c827028591e206a543397cdd37d2c2f91ae8bf3 Mon Sep 17 00:00:00 2001 From: zehsor Date: Wed, 5 Jan 2022 09:31:36 +0100 Subject: [PATCH 3/3] chore(aws-lambda-event-sources): fixed formatting --- packages/@aws-cdk/aws-lambda-event-sources/lib/kafka.ts | 1 - packages/@aws-cdk/aws-lambda-event-sources/lib/stream.ts | 5 +---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/@aws-cdk/aws-lambda-event-sources/lib/kafka.ts b/packages/@aws-cdk/aws-lambda-event-sources/lib/kafka.ts index b6060b4f91a00..1918ec2756c84 100644 --- a/packages/@aws-cdk/aws-lambda-event-sources/lib/kafka.ts +++ b/packages/@aws-cdk/aws-lambda-event-sources/lib/kafka.ts @@ -14,7 +14,6 @@ import { Construct } from '@aws-cdk/core'; * Properties for a Kafka event source */ export interface KafkaEventSourceProps extends BaseStreamEventSourceProps{ - /** * The Kafka topic to subscribe to */ diff --git a/packages/@aws-cdk/aws-lambda-event-sources/lib/stream.ts b/packages/@aws-cdk/aws-lambda-event-sources/lib/stream.ts index ccaf85b68f787..462387397b629 100644 --- a/packages/@aws-cdk/aws-lambda-event-sources/lib/stream.ts +++ b/packages/@aws-cdk/aws-lambda-event-sources/lib/stream.ts @@ -48,6 +48,7 @@ export interface BaseStreamEventSourceProps{ */ readonly enabled?: boolean; } + /** * The set of properties for event sources that follow the streaming model, * such as, Dynamo, Kinesis. @@ -70,7 +71,6 @@ export interface StreamEventSourceProps extends BaseStreamEventSourceProps { */ readonly maxRecordAge?: Duration; - /** * Maximum number of retry attempts * Valid Range: @@ -81,7 +81,6 @@ export interface StreamEventSourceProps extends BaseStreamEventSourceProps { */ readonly retryAttempts?: number; - /** * The number of batches to process from each shard concurrently. * Valid Range: @@ -92,7 +91,6 @@ export interface StreamEventSourceProps extends BaseStreamEventSourceProps { */ readonly parallelizationFactor?: number; - /** * Allow functions to return partially successful responses for a batch of records. * @@ -102,7 +100,6 @@ export interface StreamEventSourceProps extends BaseStreamEventSourceProps { */ readonly reportBatchItemFailures?: boolean; - /** * The size of the tumbling windows to group records sent to DynamoDB or Kinesis * Valid Range: 0 - 15 minutes