Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(msk-alpha): new KafkaVersions 3_7_X and 3_7_X_KRAFT #32515

Merged
merged 4 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 43 additions & 17 deletions packages/@aws-cdk/aws-msk-alpha/lib/cluster-version.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/**
* Available features for a given Kafka version
*/
export interface KafkaVersionFeatures {
/**
* Whether the Kafka version supports tiered storage mode.
*
* @see https://docs.aws.amazon.com/msk/latest/developerguide/msk-tiered-storage.html#msk-tiered-storage-requirements
* @default false
*/
readonly tieredStorage?: boolean;
}

/**
* Kafka cluster version
*/
Expand All @@ -22,11 +35,15 @@ export class KafkaVersion {

/**
* Kafka version 2.2.1
*
* @deprecated use the latest runtime instead
*/
public static readonly V2_2_1 = KafkaVersion.of('2.2.1');

/**
* Kafka version 2.3.1
*
* @deprecated use the latest runtime instead
*/
public static readonly V2_3_1 = KafkaVersion.of('2.3.1');

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

/**
* Kafka version 2.4.1
* Kafka version 2.4.1.1
*
* @deprecated use the latest runtime instead
*/
public static readonly V2_4_1_1 = KafkaVersion.of('2.4.1.1');

/**
* Kafka version 2.5.1
*
* @deprecated use the latest runtime instead
*/
public static readonly V2_5_1 = KafkaVersion.of('2.5.1');

Expand Down Expand Up @@ -97,7 +118,7 @@ export class KafkaVersion {
/**
* AWS MSK Kafka version 2.8.2.tiered
*/
public static readonly V2_8_2_TIERED = KafkaVersion.of('2.8.2.tiered');
public static readonly V2_8_2_TIERED = KafkaVersion.of('2.8.2.tiered', { tieredStorage: true });

/**
* Kafka version 3.1.1
Expand Down Expand Up @@ -132,36 +153,41 @@ export class KafkaVersion {
/**
* Kafka version 3.6.0
*/
public static readonly V3_6_0 = KafkaVersion.of('3.6.0');
public static readonly V3_6_0 = KafkaVersion.of('3.6.0', { tieredStorage: true });

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

/**
* List of Kafka versions that support tiered storage
* Kafka version 3.7.x with KRaft (Apache Kafka Raft) metadata mode support
*
* @see https://docs.aws.amazon.com/msk/latest/developerguide/msk-tiered-storage.html#msk-tiered-storage-requirements
* @see https://docs.aws.amazon.com/msk/latest/developerguide/metadata-management.html#kraft-intro
*/
private static readonly TIERED_STORAGE_COMPATIBLE_VERSIONS = [
KafkaVersion.V2_8_2_TIERED,
KafkaVersion.V3_6_0,
].map(({ version }) => version);
public static readonly V3_7_X_KRAFT = KafkaVersion.of('3.7.x.kraft', { tieredStorage: true });

/**
* Custom cluster version
* @param version custom version number
*/
public static of(version: string, features?: KafkaVersionFeatures) {
return new KafkaVersion(version, features);
}

/**
*
* @param version cluster version number
* @param features features for the cluster version
*/
private constructor(public readonly version: string) {}
private constructor(public readonly version: string, public readonly features?: KafkaVersionFeatures) {}

/**
* Checks if the cluster version supports tiered storage mode.
*/
public isTieredStorageCompatible() {
return KafkaVersion.TIERED_STORAGE_COMPATIBLE_VERSIONS.includes(this.version);
public isTieredStorageCompatible(): boolean {
return this.features?.tieredStorage ?? false;
};
}
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-msk-alpha/lib/cluster.ts
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this PR, I just noticed the lack of typing

Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ export class Cluster extends ClusterBase {
);
}

let clientAuthentication;
let clientAuthentication: CfnCluster.ClientAuthenticationProperty | undefined;
if (props.clientAuthentication?.saslProps?.iam) {
clientAuthentication = {
sasl: { iam: { enabled: props.clientAuthentication.saslProps.iam } },
Expand Down Expand Up @@ -747,7 +747,7 @@ export class Cluster extends ClusterBase {
openMonitoring: openMonitoring,
storageMode: props.storageMode,
loggingInfo: loggingInfo,
clientAuthentication: clientAuthentication,
clientAuthentication,
});

this.clusterName = this.getResourceNameAttribute(
Expand Down
5 changes: 5 additions & 0 deletions packages/@aws-cdk/aws-msk-alpha/test/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ describe('MSK Cluster', () => {
[msk.KafkaVersion.V3_3_2, '3.3.2'],
[msk.KafkaVersion.V3_4_0, '3.4.0'],
[msk.KafkaVersion.V3_5_1, '3.5.1'],
[msk.KafkaVersion.V3_6_0, '3.6.0'],
[msk.KafkaVersion.V3_7_X, '3.7.x'],
[msk.KafkaVersion.V3_7_X_KRAFT, '3.7.x.kraft'],
],
)('created with expected Kafka version %j', (parameter, result) => {
new msk.Cluster(stack, 'Cluster', {
Expand Down Expand Up @@ -794,6 +797,8 @@ describe('MSK Cluster', () => {
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();
expect(msk.KafkaVersion.V3_7_X.isTieredStorageCompatible()).toBeTruthy();
expect(msk.KafkaVersion.V3_7_X_KRAFT.isTieredStorageCompatible()).toBeTruthy();
});

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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading