You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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*
0 commit comments