Skip to content

Commit cbacf4d

Browse files
authored
feat(msk-alpha): new KafkaVersions 3_7_X and 3_7_X_KRAFT (#32515)
### Issue # (if applicable) None ### 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 Even though there is a Metadata mode input in the web console (see [announcement](https://aws.amazon.com/blogs/big-data/introducing-support-for-apache-kafka-on-raft-mode-kraft-with-amazon-msk-clusters/)), there doesn't seem to be any associated fields, and the metadata mode is only dictated by the selected version according to the [docs](https://docs.aws.amazon.com/msk/latest/developerguide/metadata-management.html#kraft-intro): > To create a cluster in KRaft mode using the MSK API CreateCluster or CreateClusterV2 operations, you should use 3.7.x.kraft as the version. Use 3.7.x as the version to create a cluster in ZooKeeper mode. Given this, I don't see a reason to add a field to the `KafkaVersion` class to differentiate between the ZooKeeper and KRaft mode. This may easily be added in the future if needed. I've also refactored the tiered array to increase maintainability and align it with other version classes, such as the RDS `EngineVersion`s. See [docs](https://docs.aws.amazon.com/msk/latest/developerguide/msk-tiered-storage.html#msk-tiered-storage-requirements) for supported versions: > The Amazon MSK cluster with tiered storage enabled must use version 3.6.0 or higher, or 2.8.2.tiered. I don't think it's worth parsing the version to automatically determine the tiered storage support, as we already have non-semver versions and support may be dropped for future versions. ### Description of how you validated changes I compared the current CDK versions to live SDK data, using the `kafka:ListKafkaVersions` API results, and updated the cluster version integration ### 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*
1 parent dc1647e commit cbacf4d

11 files changed

+437
-519
lines changed

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

+43-17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/**
2+
* Available features for a given Kafka version
3+
*/
4+
export interface KafkaVersionFeatures {
5+
/**
6+
* Whether the Kafka version supports tiered storage mode.
7+
*
8+
* @see https://docs.aws.amazon.com/msk/latest/developerguide/msk-tiered-storage.html#msk-tiered-storage-requirements
9+
* @default false
10+
*/
11+
readonly tieredStorage?: boolean;
12+
}
13+
114
/**
215
* Kafka cluster version
316
*/
@@ -22,11 +35,15 @@ export class KafkaVersion {
2235

2336
/**
2437
* Kafka version 2.2.1
38+
*
39+
* @deprecated use the latest runtime instead
2540
*/
2641
public static readonly V2_2_1 = KafkaVersion.of('2.2.1');
2742

2843
/**
2944
* Kafka version 2.3.1
45+
*
46+
* @deprecated use the latest runtime instead
3047
*/
3148
public static readonly V2_3_1 = KafkaVersion.of('2.3.1');
3249

@@ -40,12 +57,16 @@ export class KafkaVersion {
4057
public static readonly V2_4_1 = KafkaVersion.of('2.4.1');
4158

4259
/**
43-
* Kafka version 2.4.1
60+
* Kafka version 2.4.1.1
61+
*
62+
* @deprecated use the latest runtime instead
4463
*/
4564
public static readonly V2_4_1_1 = KafkaVersion.of('2.4.1.1');
4665

4766
/**
4867
* Kafka version 2.5.1
68+
*
69+
* @deprecated use the latest runtime instead
4970
*/
5071
public static readonly V2_5_1 = KafkaVersion.of('2.5.1');
5172

@@ -97,7 +118,7 @@ export class KafkaVersion {
97118
/**
98119
* AWS MSK Kafka version 2.8.2.tiered
99120
*/
100-
public static readonly V2_8_2_TIERED = KafkaVersion.of('2.8.2.tiered');
121+
public static readonly V2_8_2_TIERED = KafkaVersion.of('2.8.2.tiered', { tieredStorage: true });
101122

102123
/**
103124
* Kafka version 3.1.1
@@ -132,36 +153,41 @@ export class KafkaVersion {
132153
/**
133154
* Kafka version 3.6.0
134155
*/
135-
public static readonly V3_6_0 = KafkaVersion.of('3.6.0');
156+
public static readonly V3_6_0 = KafkaVersion.of('3.6.0', { tieredStorage: true });
136157

137158
/**
138-
* Custom cluster version
139-
* @param version custom version number
159+
* Kafka version 3.7.x with ZooKeeper metadata mode support
160+
*
161+
* @see https://docs.aws.amazon.com/msk/latest/developerguide/metadata-management.html#msk-get-connection-string
140162
*/
141-
public static of(version: string) {
142-
return new KafkaVersion(version);
143-
}
163+
public static readonly V3_7_X = KafkaVersion.of('3.7.x', { tieredStorage: true });
144164

145165
/**
146-
* List of Kafka versions that support tiered storage
166+
* Kafka version 3.7.x with KRaft (Apache Kafka Raft) metadata mode support
147167
*
148-
* @see https://docs.aws.amazon.com/msk/latest/developerguide/msk-tiered-storage.html#msk-tiered-storage-requirements
168+
* @see https://docs.aws.amazon.com/msk/latest/developerguide/metadata-management.html#kraft-intro
149169
*/
150-
private static readonly TIERED_STORAGE_COMPATIBLE_VERSIONS = [
151-
KafkaVersion.V2_8_2_TIERED,
152-
KafkaVersion.V3_6_0,
153-
].map(({ version }) => version);
170+
public static readonly V3_7_X_KRAFT = KafkaVersion.of('3.7.x.kraft', { tieredStorage: true });
171+
172+
/**
173+
* Custom cluster version
174+
* @param version custom version number
175+
*/
176+
public static of(version: string, features?: KafkaVersionFeatures) {
177+
return new KafkaVersion(version, features);
178+
}
154179

155180
/**
156181
*
157182
* @param version cluster version number
183+
* @param features features for the cluster version
158184
*/
159-
private constructor(public readonly version: string) {}
185+
private constructor(public readonly version: string, public readonly features?: KafkaVersionFeatures) {}
160186

161187
/**
162188
* Checks if the cluster version supports tiered storage mode.
163189
*/
164-
public isTieredStorageCompatible() {
165-
return KafkaVersion.TIERED_STORAGE_COMPATIBLE_VERSIONS.includes(this.version);
190+
public isTieredStorageCompatible(): boolean {
191+
return this.features?.tieredStorage ?? false;
166192
};
167193
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ export class Cluster extends ClusterBase {
685685
);
686686
}
687687

688-
let clientAuthentication;
688+
let clientAuthentication: CfnCluster.ClientAuthenticationProperty | undefined;
689689
if (props.clientAuthentication?.saslProps?.iam) {
690690
clientAuthentication = {
691691
sasl: { iam: { enabled: props.clientAuthentication.saslProps.iam } },
@@ -747,7 +747,7 @@ export class Cluster extends ClusterBase {
747747
openMonitoring: openMonitoring,
748748
storageMode: props.storageMode,
749749
loggingInfo: loggingInfo,
750-
clientAuthentication: clientAuthentication,
750+
clientAuthentication,
751751
});
752752

753753
this.clusterName = this.getResourceNameAttribute(

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

+5
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ describe('MSK Cluster', () => {
4444
[msk.KafkaVersion.V3_3_2, '3.3.2'],
4545
[msk.KafkaVersion.V3_4_0, '3.4.0'],
4646
[msk.KafkaVersion.V3_5_1, '3.5.1'],
47+
[msk.KafkaVersion.V3_6_0, '3.6.0'],
48+
[msk.KafkaVersion.V3_7_X, '3.7.x'],
49+
[msk.KafkaVersion.V3_7_X_KRAFT, '3.7.x.kraft'],
4750
],
4851
)('created with expected Kafka version %j', (parameter, result) => {
4952
new msk.Cluster(stack, 'Cluster', {
@@ -794,6 +797,8 @@ describe('MSK Cluster', () => {
794797
expect(msk.KafkaVersion.V2_8_2_TIERED.isTieredStorageCompatible()).toBeTruthy();
795798
expect(msk.KafkaVersion.V3_5_1.isTieredStorageCompatible()).toBeFalsy();
796799
expect(msk.KafkaVersion.V3_6_0.isTieredStorageCompatible()).toBeTruthy();
800+
expect(msk.KafkaVersion.V3_7_X.isTieredStorageCompatible()).toBeTruthy();
801+
expect(msk.KafkaVersion.V3_7_X_KRAFT.isTieredStorageCompatible()).toBeTruthy();
797802
});
798803

799804
test('create a cluster with tiered storage mode', () => {

packages/@aws-cdk/aws-msk-alpha/test/integ.cluster-version.js.snapshot/KafkaVersionIntegTestDefaultTestDeployAssertD6628743.assets.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-msk-alpha/test/integ.cluster-version.js.snapshot/KafkaVersionTestStack.assets.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)