Skip to content

Commit 41ddd46

Browse files
authored
fix(msk): clusterName validation in Cluster class is incorrect (#32792)
### Issue # (if applicable) N/A ### Reason for this change The validation for clusterName is incorrect. There are two issues: 1. The AND (&&) operators should be OR (||) operators. Currently, the validation throws an error only when both the pattern check AND length check fail. However, it should throw an error when EITHER check fails. ```ts if ( !core.Token.isUnresolved(props.clusterName) && !/^[a-zA-Z0-9]+$/.test(props.clusterName) && props.clusterName.length > 64 ) ``` 2. The pattern check is too restrictive. The current validation only allows alphanumeric characters, but hyphens (-) should also be allowed. <img width="768" alt="image" src="https://github.com/user-attachments/assets/a53f240d-66f9-4ee1-890e-30f1fecd4a4a" /> Additionally, the error message in the AWS Management Console appears to be inconsistent with the actual validation requirements. <img width="802" alt="image" src="https://github.com/user-attachments/assets/8aacc3b4-b85e-45c6-9e95-5de70416e069" /> ### Description of changes Removed cluster name validation due to the following reasons: * The current validation is incorrect and not functioning as intended. * While the correct pattern is not documented in [CFn docs](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-msk-cluster.html#cfn-msk-cluster-clustername). So updating the validation might introduce regressions. * As suggested by maintainers' comments, there is an opinion that pattern validation should not be implemented in CDK. [Ref](#32505 (comment)) Since the correct pattern is not documented clearly, I think removing the validation would be the preferable approach. ### Describe any new or updated permissions being added Nothing. ### Description of how you validated changes Nothing because only remove validation. ### 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 e33ebb4 commit 41ddd46

File tree

1 file changed

+0
-11
lines changed

1 file changed

+0
-11
lines changed

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -485,17 +485,6 @@ export class Cluster extends ClusterBase {
485485
);
486486
}
487487

488-
if (
489-
!core.Token.isUnresolved(props.clusterName) &&
490-
!/^[a-zA-Z0-9]+$/.test(props.clusterName) &&
491-
props.clusterName.length > 64
492-
) {
493-
throw Error(
494-
'The cluster name must only contain alphanumeric characters and have a maximum length of 64 characters.' +
495-
`got: '${props.clusterName}. length: ${props.clusterName.length}'`,
496-
);
497-
}
498-
499488
if (
500489
props.clientAuthentication?.saslProps?.iam &&
501490
props.clientAuthentication?.saslProps?.scram

0 commit comments

Comments
 (0)