Skip to content

Commit aa40e38

Browse files
authored
feat(msk): support Kafka 4.0 (#34501)
### Issue # (if applicable) N/A ### Reason for this change MS support Apache Kafka version 4.0. ### Description of changes Add ver 4.0 enum. Kafka version 4.0 only supports KRaft (Apache Kafka Raft). ### Describe any new or updated permissions being added nothing. ### Description of how you validated changes Add a unit test and an integ test. ### 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 3f35c70 commit aa40e38

File tree

9 files changed

+122
-15
lines changed

9 files changed

+122
-15
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The following example creates an MSK Cluster.
2323
declare const vpc: ec2.Vpc;
2424
const cluster = new msk.Cluster(this, 'Cluster', {
2525
clusterName: 'myCluster',
26-
kafkaVersion: msk.KafkaVersion.V3_9_X,
26+
kafkaVersion: msk.KafkaVersion.V4_0_X_KRAFT,
2727
vpc,
2828
});
2929
```
@@ -36,7 +36,7 @@ To control who can access the Cluster, use the `.connections` attribute. For a l
3636
declare const vpc: ec2.Vpc;
3737
const cluster = new msk.Cluster(this, 'Cluster', {
3838
clusterName: 'myCluster',
39-
kafkaVersion: msk.KafkaVersion.V3_9_X,
39+
kafkaVersion: msk.KafkaVersion.V4_0_X_KRAFT,
4040
vpc,
4141
});
4242

@@ -88,7 +88,7 @@ import * as acmpca from 'aws-cdk-lib/aws-acmpca';
8888
declare const vpc: ec2.Vpc;
8989
const cluster = new msk.Cluster(this, 'Cluster', {
9090
clusterName: 'myCluster',
91-
kafkaVersion: msk.KafkaVersion.V3_9_X,
91+
kafkaVersion: msk.KafkaVersion.V4_0_X_KRAFT,
9292
vpc,
9393
encryptionInTransit: {
9494
clientBroker: msk.ClientBrokerEncryption.TLS,
@@ -113,7 +113,7 @@ Enable client authentication with [SASL/SCRAM](https://docs.aws.amazon.com/msk/l
113113
declare const vpc: ec2.Vpc;
114114
const cluster = new msk.Cluster(this, 'cluster', {
115115
clusterName: 'myCluster',
116-
kafkaVersion: msk.KafkaVersion.V3_9_X,
116+
kafkaVersion: msk.KafkaVersion.V4_0_X_KRAFT,
117117
vpc,
118118
encryptionInTransit: {
119119
clientBroker: msk.ClientBrokerEncryption.TLS,
@@ -132,7 +132,7 @@ Enable client authentication with [IAM](https://docs.aws.amazon.com/msk/latest/d
132132
declare const vpc: ec2.Vpc;
133133
const cluster = new msk.Cluster(this, 'cluster', {
134134
clusterName: 'myCluster',
135-
kafkaVersion: msk.KafkaVersion.V3_9_X,
135+
kafkaVersion: msk.KafkaVersion.V4_0_X_KRAFT,
136136
vpc,
137137
encryptionInTransit: {
138138
clientBroker: msk.ClientBrokerEncryption.TLS,
@@ -155,7 +155,7 @@ import * as acmpca from 'aws-cdk-lib/aws-acmpca';
155155
declare const vpc: ec2.Vpc;
156156
const cluster = new msk.Cluster(this, 'Cluster', {
157157
clusterName: 'myCluster',
158-
kafkaVersion: msk.KafkaVersion.V3_9_X,
158+
kafkaVersion: msk.KafkaVersion.V4_0_X_KRAFT,
159159
vpc,
160160
encryptionInTransit: {
161161
clientBroker: msk.ClientBrokerEncryption.TLS,
@@ -186,7 +186,7 @@ declare const vpc: ec2.Vpc;
186186
declare const bucket: s3.IBucket;
187187
const cluster = new msk.Cluster(this, 'cluster', {
188188
clusterName: 'myCluster',
189-
kafkaVersion: msk.KafkaVersion.V3_9_X,
189+
kafkaVersion: msk.KafkaVersion.V4_0_X_KRAFT,
190190
vpc,
191191
logging: {
192192
s3: {
@@ -226,7 +226,7 @@ declare const bucket: s3.IBucket;
226226

227227
const cluster = new msk.Cluster(this, 'cluster', {
228228
clusterName: 'myCluster',
229-
kafkaVersion: msk.KafkaVersion.V3_9_X,
229+
kafkaVersion: msk.KafkaVersion.V4_0_X_KRAFT,
230230
vpc,
231231
storageMode: msk.StorageMode.TIERED,
232232
});

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,14 @@ export class KafkaVersion {
224224
* @see https://docs.aws.amazon.com/msk/latest/developerguide/metadata-management.html#kraft-intro
225225
*/
226226
public static readonly V3_9_X_KRAFT = KafkaVersion.of('3.9.x.kraft', { tieredStorage: true });
227+
228+
/**
229+
* Kafka version 4.0.x with KRaft (Apache Kafka Raft) metadata mode support
230+
*
231+
* @see https://docs.aws.amazon.com/msk/latest/developerguide/metadata-management.html#kraft-intro
232+
*/
233+
public static readonly V4_0_X_KRAFT = KafkaVersion.of('4.0.x.kraft', { tieredStorage: true });
234+
227235
/**
228236
* Custom cluster version
229237
* @param version custom version number

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ describe('MSK Cluster', () => {
5151
[msk.KafkaVersion.V3_8_X_KRAFT, '3.8.x.kraft'],
5252
[msk.KafkaVersion.V3_9_X, '3.9.x'],
5353
[msk.KafkaVersion.V3_9_X_KRAFT, '3.9.x.kraft'],
54+
[msk.KafkaVersion.V4_0_X_KRAFT, '4.0.x.kraft'],
5455
],
5556
)('created with expected Kafka version %j', (parameter, result) => {
5657
new msk.Cluster(stack, 'Cluster', {

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

Lines changed: 2 additions & 2 deletions
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.template.json

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,6 +1977,75 @@
19771977
},
19781978
"UpdateReplacePolicy": "Delete",
19791979
"DeletionPolicy": "Delete"
1980+
},
1981+
"ClusterVersion40xkraftSecurityGroup81D50A3C": {
1982+
"Type": "AWS::EC2::SecurityGroup",
1983+
"Properties": {
1984+
"GroupDescription": "MSK security group",
1985+
"SecurityGroupEgress": [
1986+
{
1987+
"CidrIp": "0.0.0.0/0",
1988+
"Description": "Allow all outbound traffic by default",
1989+
"IpProtocol": "-1"
1990+
}
1991+
],
1992+
"VpcId": {
1993+
"Ref": "Vpc8378EB38"
1994+
}
1995+
}
1996+
},
1997+
"ClusterVersion40xkraft5E11CA80": {
1998+
"Type": "AWS::MSK::Cluster",
1999+
"Properties": {
2000+
"BrokerNodeGroupInfo": {
2001+
"ClientSubnets": [
2002+
{
2003+
"Ref": "VpcPrivateSubnet1Subnet536B997A"
2004+
},
2005+
{
2006+
"Ref": "VpcPrivateSubnet2Subnet3788AAA1"
2007+
}
2008+
],
2009+
"InstanceType": "kafka.m5.large",
2010+
"SecurityGroups": [
2011+
{
2012+
"Fn::GetAtt": [
2013+
"ClusterVersion40xkraftSecurityGroup81D50A3C",
2014+
"GroupId"
2015+
]
2016+
}
2017+
],
2018+
"StorageInfo": {
2019+
"EBSStorageInfo": {
2020+
"VolumeSize": 1000
2021+
}
2022+
}
2023+
},
2024+
"ClusterName": "cluster-v4-0-x-kraft",
2025+
"EncryptionInfo": {
2026+
"EncryptionInTransit": {
2027+
"ClientBroker": "TLS",
2028+
"InCluster": true
2029+
}
2030+
},
2031+
"KafkaVersion": "4.0.x.kraft",
2032+
"LoggingInfo": {
2033+
"BrokerLogs": {
2034+
"CloudWatchLogs": {
2035+
"Enabled": false
2036+
},
2037+
"Firehose": {
2038+
"Enabled": false
2039+
},
2040+
"S3": {
2041+
"Enabled": false
2042+
}
2043+
}
2044+
},
2045+
"NumberOfBrokerNodes": 2
2046+
},
2047+
"UpdateReplacePolicy": "Delete",
2048+
"DeletionPolicy": "Delete"
19802049
}
19812050
},
19822051
"Parameters": {

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

Lines changed: 2 additions & 1 deletion
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/manifest.json

Lines changed: 30 additions & 3 deletions
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/tree.json

Lines changed: 1 addition & 1 deletion
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.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const versions: KafkaVersion[] = [
2929
KafkaVersion.V3_8_X_KRAFT,
3030
KafkaVersion.V3_9_X,
3131
KafkaVersion.V3_9_X_KRAFT,
32+
KafkaVersion.V4_0_X_KRAFT,
3233
];
3334

3435
class KafkaVersionTest extends Stack {

0 commit comments

Comments
 (0)