Skip to content

Commit 4582ac5

Browse files
nmussyGavinZZ
andauthored
chore(msk-alpha): update KafkaVersion (#29440)
### Issue # (if applicable) Could not find any in the backlog ### Reason for this change Update the CDK listed Kafka versions to match the current availability, as well as add missing deprecated versions ### Description of changes * Added latest version * `3.6.0` also supports tiered storage, see [docs](https://docs.aws.amazon.com/msk/latest/developerguide/msk-tiered-storage.html#msk-tiered-storage-requirements). I replaced the prefix check with a list of supported versions, as I'm not sure if say every reason after 3.6.0 will support it, and the `.tiered` prefix isn't consistently applied anymore * Added two unlisted, deprecated versions, as they are still returned by the SDK. The goal is to remove any differences between the SDK and the CDK to ease future automation ### Description of how you validated changes I compared the current CDK versions to live SDK data, using the `kafka:ListKafkaVersions` API results. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --------- Co-authored-by: GZ <[email protected]>
1 parent 00e8a7b commit 4582ac5

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed

packages/@aws-cdk/aws-msk-alpha/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,16 @@ You can configure an MSK cluster storage mode using the `storageMode` property.
217217
Tiered storage is a low-cost storage tier for Amazon MSK that scales to virtually unlimited storage,
218218
making it cost-effective to build streaming data applications.
219219

220-
> Visit [Tiered storage](https://docs.aws.amazon.com/msk/latest/developerguide/msk-tiered-storage.html) for more details.
220+
> Visit [Tiered storage](https://docs.aws.amazon.com/msk/latest/developerguide/msk-tiered-storage.html)
221+
to see the list of compatible Kafka versions and for more details.
221222

222223
```ts
223224
declare const vpc: ec2.Vpc;
224225
declare const bucket: s3.IBucket;
225226

226227
const cluster = new msk.Cluster(this, 'cluster', {
227228
clusterName: 'myCluster',
228-
kafkaVersion: msk.KafkaVersion.V2_8_2_TIERED,
229+
kafkaVersion: msk.KafkaVersion.V3_6_0,
229230
vpc,
230231
storageMode: msk.StorageMode.TIERED,
231232
});

packages/@aws-cdk/aws-msk-alpha/lib/cluster-version.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ export class KafkaVersion {
1111
*/
1212
public static readonly V1_1_1 = KafkaVersion.of('1.1.1');
1313

14+
/**
15+
* **Deprecated by Amazon MSK. You can't create a Kafka cluster with a deprecated version.**
16+
*
17+
* Kafka version 2.1.0
18+
*
19+
* @deprecated use the latest runtime instead
20+
*/
21+
public static readonly V2_1_0 = KafkaVersion.of('2.1.0');
22+
1423
/**
1524
* Kafka version 2.2.1
1625
*/
@@ -21,6 +30,15 @@ export class KafkaVersion {
2130
*/
2231
public static readonly V2_3_1 = KafkaVersion.of('2.3.1');
2332

33+
/**
34+
* **Deprecated by Amazon MSK. You can't create a Kafka cluster with a deprecated version.**
35+
*
36+
* Kafka version 2.4.1
37+
*
38+
* @deprecated use the latest runtime instead
39+
*/
40+
public static readonly V2_4_1 = KafkaVersion.of('2.4.1');
41+
2442
/**
2543
* Kafka version 2.4.1
2644
*/
@@ -111,6 +129,11 @@ export class KafkaVersion {
111129
*/
112130
public static readonly V3_5_1 = KafkaVersion.of('3.5.1');
113131

132+
/**
133+
* Kafka version 3.6.0
134+
*/
135+
public static readonly V3_6_0 = KafkaVersion.of('3.6.0');
136+
114137
/**
115138
* Custom cluster version
116139
* @param version custom version number
@@ -119,6 +142,16 @@ export class KafkaVersion {
119142
return new KafkaVersion(version);
120143
}
121144

145+
/**
146+
* List of Kafka versions that support tiered storage
147+
*
148+
* @see https://docs.aws.amazon.com/msk/latest/developerguide/msk-tiered-storage.html#msk-tiered-storage-requirements
149+
*/
150+
private static readonly TIERED_STORAGE_COMPATIBLE_VERSIONS = [
151+
KafkaVersion.V2_8_2_TIERED,
152+
KafkaVersion.V3_6_0,
153+
].map(({ version }) => version);
154+
122155
/**
123156
*
124157
* @param version cluster version number
@@ -129,6 +162,6 @@ export class KafkaVersion {
129162
* Checks if the cluster version supports tiered storage mode.
130163
*/
131164
public isTieredStorageCompatible() {
132-
return this.version.endsWith('.tiered');
165+
return KafkaVersion.TIERED_STORAGE_COMPATIBLE_VERSIONS.includes(this.version);
133166
};
134167
}

packages/@aws-cdk/aws-msk-alpha/test/cluster.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,14 +790,20 @@ describe('MSK Cluster', () => {
790790

791791
describe('created with storage mode', () => {
792792
describe('with tiered storage mode', () => {
793+
test('version.isTieredStorageCompatible', () => {
794+
expect(msk.KafkaVersion.V2_8_2_TIERED.isTieredStorageCompatible()).toBeTruthy();
795+
expect(msk.KafkaVersion.V3_5_1.isTieredStorageCompatible()).toBeFalsy();
796+
expect(msk.KafkaVersion.V3_6_0.isTieredStorageCompatible()).toBeTruthy();
797+
});
798+
793799
test('create a cluster with tiered storage mode', () => {
794800
new msk.Cluster(stack, 'Cluster', {
795801
clusterName: 'cluster',
796802
instanceType: ec2.InstanceType.of(ec2.InstanceClass.M5, ec2.InstanceSize.LARGE),
797803
kafkaVersion: msk.KafkaVersion.V2_8_2_TIERED,
798804
vpc,
799805
storageMode: msk.StorageMode.TIERED,
800-
}),
806+
});
801807
Template.fromStack(stack).hasResourceProperties('AWS::MSK::Cluster', {
802808
StorageMode: 'TIERED',
803809
});

0 commit comments

Comments
 (0)