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
feat(eks): throw ValidationErrors instead of untyped errors (#34428)
### Issue
Relates to #32569
### Reason for this change
untyped Errors are not recommended
### Description of changes
`ValidationError`s everywhere
### Describe any new or updated permissions being added
None
### Description of how you validated changes
Existing tests. Exemptions granted as this is a refactor of existing code.
### 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*
thrownewError('ConfigMap not supported in the AuthenticationMode');
48
+
thrownewValidationError('ConfigMap not supported in the AuthenticationMode',this);
49
49
}
50
50
51
51
this.stack=Stack.of(this);
@@ -123,7 +123,7 @@ export class AwsAuth extends Construct {
123
123
// a dependency on the cluster, allowing those resources to be in a different stack,
124
124
// will create a circular dependency. granted, it won't always be the case,
125
125
// but we opted for the more cautious and restrictive approach for now.
126
-
thrownewError(`${construct.node.path} should be defined in the scope of the ${thisStack.stackName} stack to prevent circular dependencies`);
126
+
thrownewValidationError(`${construct.node.path} should be defined in the scope of the ${thisStack.stackName} stack to prevent circular dependencies`,this);
thrownewError('CIDR blocks can only be configured when public access is enabled');
785
+
thrownewUnscopedValidationError('CIDR blocks can only be configured when public access is enabled');
786
786
}
787
787
}
788
788
@@ -796,7 +796,7 @@ export class EndpointAccess {
796
796
if(!this._config.privateAccess){
797
797
// when private access is disabled, we can't restric public
798
798
// access since it will render the kubectl provider unusable.
799
-
thrownewError('Cannot restric public access to endpoint when private access is disabled. Use PUBLIC_AND_PRIVATE.onlyFrom() instead.');
799
+
thrownewUnscopedValidationError('Cannot restric public access to endpoint when private access is disabled. Use PUBLIC_AND_PRIVATE.onlyFrom() instead.');
thrownewError('eks.Cluster: cannot select multiple subnet groups from a VPC imported from list tokens with unknown length. Select only one subnet group, pass a length to Fn.split, or switch to Vpc.fromLookup.');
1629
+
thrownewValidationError('eks.Cluster: cannot select multiple subnet groups from a VPC imported from list tokens with unknown length. Select only one subnet group, pass a length to Fn.split, or switch to Vpc.fromLookup.',this);
1630
1630
}
1631
1631
1632
1632
// Get subnetIds for all selected subnets
@@ -1665,29 +1665,29 @@ export class Cluster extends ClusterBase {
thrownewError('Private endpoint access requires the VPC to have DNS support and DNS hostnames enabled. Use `enableDnsHostnames: true` and `enableDnsSupport: true` when creating the VPC.');
1748
+
thrownewValidationError('Private endpoint access requires the VPC to have DNS support and DNS hostnames enabled. Use `enableDnsHostnames: true` and `enableDnsSupport: true` when creating the VPC.',this);
1749
1749
}
1750
1750
1751
1751
this.kubectlPrivateSubnets=privateSubnets;
@@ -1934,7 +1934,7 @@ export class Cluster extends ClusterBase {
thrownewError(`CIDR block ${remoteNodeCidr1} in remote node network #${i+1} should not overlap with CIDR block ${remoteNodeCidr2} in remote node network #${i+j+2}`);
2278
+
thrownewValidationError(`CIDR block ${remoteNodeCidr1} in remote node network #${i+1} should not overlap with CIDR block ${remoteNodeCidr2} in remote node network #${i+j+2}`,this);
2279
2279
}
2280
2280
});
2281
2281
});
@@ -2287,7 +2287,7 @@ export class Cluster extends ClusterBase {
thrownewError(`CIDR block ${remotePodCidr1} in remote pod network #${i+1} should not overlap with CIDR block ${remotePodCidr2} in remote pod network #${i+j+2}`);
2301
+
thrownewValidationError(`CIDR block ${remotePodCidr1} in remote pod network #${i+1} should not overlap with CIDR block ${remotePodCidr2} in remote pod network #${i+j+2}`,this);
2302
2302
}
2303
2303
});
2304
2304
});
@@ -2308,7 +2308,7 @@ export class Cluster extends ClusterBase {
thrownewError(`Remote node network CIDR block ${remoteNodeCidr} should not overlap with remote pod network CIDR block ${remotePodCidr}`);
2311
+
thrownewValidationError(`Remote node network CIDR block ${remoteNodeCidr} should not overlap with remote pod network CIDR block ${remotePodCidr}`,this);
2312
2312
}
2313
2313
}
2314
2314
}
@@ -2563,55 +2563,55 @@ class ImportedCluster extends ClusterBase {
2563
2563
2564
2564
publicgetvpc(){
2565
2565
if(!this.props.vpc){
2566
-
thrownewError('"vpc" is not defined for this imported cluster');
2566
+
thrownewValidationError('"vpc" is not defined for this imported cluster',this);
0 commit comments