From e6c6bf8e265ba20b3707bc6506c70afa4038536d Mon Sep 17 00:00:00 2001 From: Jimmy Gaussen Date: Mon, 11 Mar 2024 15:28:56 +0100 Subject: [PATCH 1/6] chore(msk-alpha): update KafkaVersion --- .../aws-msk-alpha/lib/cluster-version.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/packages/@aws-cdk/aws-msk-alpha/lib/cluster-version.ts b/packages/@aws-cdk/aws-msk-alpha/lib/cluster-version.ts index 405c0c6ee0ecc..dc76a38804b7a 100644 --- a/packages/@aws-cdk/aws-msk-alpha/lib/cluster-version.ts +++ b/packages/@aws-cdk/aws-msk-alpha/lib/cluster-version.ts @@ -11,6 +11,15 @@ export class KafkaVersion { */ public static readonly V1_1_1 = KafkaVersion.of('1.1.1'); + /** + * **Deprecated by Amazon MSK. You can't create a Kafka cluster with a deprecated version.** + * + * Kafka version 2.1.0 + * + * @deprecated use the latest runtime instead + */ + public static readonly V2_1_0 = KafkaVersion.of('2.1.0'); + /** * Kafka version 2.2.1 */ @@ -21,6 +30,15 @@ export class KafkaVersion { */ public static readonly V2_3_1 = KafkaVersion.of('2.3.1'); + /** + * **Deprecated by Amazon MSK. You can't create a Kafka cluster with a deprecated version.** + * + * Kafka version 2.4.1 + * + * @deprecated use the latest runtime instead + */ + public static readonly V2_4_1 = KafkaVersion.of('2.4.1'); + /** * Kafka version 2.4.1 */ @@ -111,6 +129,11 @@ export class KafkaVersion { */ public static readonly V3_5_1 = KafkaVersion.of('3.5.1'); + /** + * Kafka version 3.6.0 + */ + public static readonly V3_6_0 = KafkaVersion.of('3.6.0'); + /** * Custom cluster version * @param version custom version number From 16f1fd48374a99aff958452a7b6da890f31a13a2 Mon Sep 17 00:00:00 2001 From: Jimmy Gaussen Date: Mon, 11 Mar 2024 15:44:59 +0100 Subject: [PATCH 2/6] chore: replace comma --- packages/@aws-cdk/aws-msk-alpha/test/cluster.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-msk-alpha/test/cluster.test.ts b/packages/@aws-cdk/aws-msk-alpha/test/cluster.test.ts index babbb235b40a3..2bf9831643fe3 100644 --- a/packages/@aws-cdk/aws-msk-alpha/test/cluster.test.ts +++ b/packages/@aws-cdk/aws-msk-alpha/test/cluster.test.ts @@ -797,7 +797,7 @@ describe('MSK Cluster', () => { kafkaVersion: msk.KafkaVersion.V2_8_2_TIERED, vpc, storageMode: msk.StorageMode.TIERED, - }), + }); Template.fromStack(stack).hasResourceProperties('AWS::MSK::Cluster', { StorageMode: 'TIERED', }); From 15ead922ae8b15e39d6e54d23fd0956b2ee46a5d Mon Sep 17 00:00:00 2001 From: Jimmy Gaussen Date: Mon, 11 Mar 2024 15:47:28 +0100 Subject: [PATCH 3/6] fix: add TIERED_STORAGE_COMPATIBLE_VERSIONS --- .../@aws-cdk/aws-msk-alpha/lib/cluster-version.ts | 12 +++++++++++- packages/@aws-cdk/aws-msk-alpha/test/cluster.test.ts | 6 ++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-msk-alpha/lib/cluster-version.ts b/packages/@aws-cdk/aws-msk-alpha/lib/cluster-version.ts index dc76a38804b7a..3536db60c9b6b 100644 --- a/packages/@aws-cdk/aws-msk-alpha/lib/cluster-version.ts +++ b/packages/@aws-cdk/aws-msk-alpha/lib/cluster-version.ts @@ -148,10 +148,20 @@ export class KafkaVersion { */ private constructor(public readonly version: string) {} + /** + * List of Kafka versions that support tiered storage + * + * @see https://docs.aws.amazon.com/msk/latest/developerguide/msk-tiered-storage.html#msk-tiered-storage-requirements + */ + private static readonly TIERED_STORAGE_COMPATIBLE_VERSIONS = [ + KafkaVersion.V2_8_2_TIERED, + KafkaVersion.V3_6_0, + ].map(({version}) => version); + /** * Checks if the cluster version supports tiered storage mode. */ public isTieredStorageCompatible() { - return this.version.endsWith('.tiered'); + return KafkaVersion.TIERED_STORAGE_COMPATIBLE_VERSIONS.includes(this.version); }; } diff --git a/packages/@aws-cdk/aws-msk-alpha/test/cluster.test.ts b/packages/@aws-cdk/aws-msk-alpha/test/cluster.test.ts index 2bf9831643fe3..7c4bd6a10f4ec 100644 --- a/packages/@aws-cdk/aws-msk-alpha/test/cluster.test.ts +++ b/packages/@aws-cdk/aws-msk-alpha/test/cluster.test.ts @@ -790,6 +790,12 @@ describe('MSK Cluster', () => { describe('created with storage mode', () => { describe('with tiered storage mode', () => { + test('version.isTieredStorageCompatible', () => { + expect(msk.KafkaVersion.V2_8_2_TIERED.isTieredStorageCompatible()).toBeTruthy(); + expect(msk.KafkaVersion.V3_5_1.isTieredStorageCompatible()).toBeFalsy(); + expect(msk.KafkaVersion.V3_6_0.isTieredStorageCompatible()).toBeTruthy(); + }); + test('create a cluster with tiered storage mode', () => { new msk.Cluster(stack, 'Cluster', { clusterName: 'cluster', From b0a0fd5aaac41fcaeaabfbb08c44aaca91335a22 Mon Sep 17 00:00:00 2001 From: Jimmy Gaussen Date: Mon, 11 Mar 2024 16:34:09 +0100 Subject: [PATCH 4/6] chore: lint fixes --- .../aws-msk-alpha/lib/cluster-version.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/@aws-cdk/aws-msk-alpha/lib/cluster-version.ts b/packages/@aws-cdk/aws-msk-alpha/lib/cluster-version.ts index 3536db60c9b6b..4618b13382004 100644 --- a/packages/@aws-cdk/aws-msk-alpha/lib/cluster-version.ts +++ b/packages/@aws-cdk/aws-msk-alpha/lib/cluster-version.ts @@ -134,6 +134,16 @@ export class KafkaVersion { */ public static readonly V3_6_0 = KafkaVersion.of('3.6.0'); + /** + * List of Kafka versions that support tiered storage + * + * @see https://docs.aws.amazon.com/msk/latest/developerguide/msk-tiered-storage.html#msk-tiered-storage-requirements + */ + private static readonly TIERED_STORAGE_COMPATIBLE_VERSIONS = [ + KafkaVersion.V2_8_2_TIERED, + KafkaVersion.V3_6_0, + ].map(({ version }) => version); + /** * Custom cluster version * @param version custom version number @@ -148,16 +158,6 @@ export class KafkaVersion { */ private constructor(public readonly version: string) {} - /** - * List of Kafka versions that support tiered storage - * - * @see https://docs.aws.amazon.com/msk/latest/developerguide/msk-tiered-storage.html#msk-tiered-storage-requirements - */ - private static readonly TIERED_STORAGE_COMPATIBLE_VERSIONS = [ - KafkaVersion.V2_8_2_TIERED, - KafkaVersion.V3_6_0, - ].map(({version}) => version); - /** * Checks if the cluster version supports tiered storage mode. */ From ea5bc9a47ed0451d9846556f13ed74b9c6340912 Mon Sep 17 00:00:00 2001 From: Jimmy Gaussen Date: Mon, 11 Mar 2024 17:10:52 +0100 Subject: [PATCH 5/6] chore: lint fixes --- .../aws-msk-alpha/lib/cluster-version.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/@aws-cdk/aws-msk-alpha/lib/cluster-version.ts b/packages/@aws-cdk/aws-msk-alpha/lib/cluster-version.ts index 4618b13382004..b3c5277018b1c 100644 --- a/packages/@aws-cdk/aws-msk-alpha/lib/cluster-version.ts +++ b/packages/@aws-cdk/aws-msk-alpha/lib/cluster-version.ts @@ -134,6 +134,14 @@ export class KafkaVersion { */ public static readonly V3_6_0 = KafkaVersion.of('3.6.0'); + /** + * Custom cluster version + * @param version custom version number + */ + public static of(version: string) { + return new KafkaVersion(version); + } + /** * List of Kafka versions that support tiered storage * @@ -144,14 +152,6 @@ export class KafkaVersion { KafkaVersion.V3_6_0, ].map(({ version }) => version); - /** - * Custom cluster version - * @param version custom version number - */ - public static of(version: string) { - return new KafkaVersion(version); - } - /** * * @param version cluster version number From d31f6bf38a7ab1c6f6cdd448135bbea63562a7f1 Mon Sep 17 00:00:00 2001 From: Jimmy Gaussen Date: Tue, 12 Mar 2024 19:42:22 +0100 Subject: [PATCH 6/6] chore: update README --- packages/@aws-cdk/aws-msk-alpha/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/aws-msk-alpha/README.md b/packages/@aws-cdk/aws-msk-alpha/README.md index 81b74be3aa279..8155f8829a756 100644 --- a/packages/@aws-cdk/aws-msk-alpha/README.md +++ b/packages/@aws-cdk/aws-msk-alpha/README.md @@ -217,7 +217,8 @@ You can configure an MSK cluster storage mode using the `storageMode` property. Tiered storage is a low-cost storage tier for Amazon MSK that scales to virtually unlimited storage, making it cost-effective to build streaming data applications. -> Visit [Tiered storage](https://docs.aws.amazon.com/msk/latest/developerguide/msk-tiered-storage.html) for more details. +> Visit [Tiered storage](https://docs.aws.amazon.com/msk/latest/developerguide/msk-tiered-storage.html) +to see the list of compatible Kafka versions and for more details. ```ts declare const vpc: ec2.Vpc; @@ -225,7 +226,7 @@ declare const bucket: s3.IBucket; const cluster = new msk.Cluster(this, 'cluster', { clusterName: 'myCluster', - kafkaVersion: msk.KafkaVersion.V2_8_2_TIERED, + kafkaVersion: msk.KafkaVersion.V3_6_0, vpc, storageMode: msk.StorageMode.TIERED, });