Open
Description
Describe the bug
We cannot use multiple EKS clusters within the same stack.
It seems that the cause is the hardcoded ID of the KubectlLayer
.
Regression Issue
- Select this option if this issue appears to be a regression.
Last Known Working CDK Version
2.160.0
Expected Behavior
Deploys successfully.
Current Behavior
Fails to deploy.
Reproduction Steps
import * as eks from 'aws-cdk-lib/aws-eks';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import { getClusterVersionConfig } from './integ-tests-kubernetes-version';
class MultipleEksClusterStack extends Stack {
constructor(scope: App, id: string) {
super(scope, id);
const vpc = new ec2.Vpc(this, 'Vpc', { natGateways: 1 });
new eks.Cluster(this, 'EnabledCluster', {
vpc,
...getClusterVersionConfig(this, eks.KubernetesVersion.V1_30),
bootstrapSelfManagedAddons: true,
});
new eks.Cluster(this, 'DisabledCluster', {
vpc,
...getClusterVersionConfig(this, eks.KubernetesVersion.V1_30),
bootstrapSelfManagedAddons: false,
});
}
}
Results
/Users/kazuhoshinozuka/git/aws-cdk/node_modules/constructs/lib/construct.js:375
throw new Error(`There is already a Construct with name '${childName}' in ${typeName}${name.length > 0 ? ' [' + name + ']' : ''}`);
^
Error: There is already a Construct with name 'KubectlLayer' in MultipleEksClusterStack [EksClusterStack]
at Node.addChild (/Users/kazuhoshinozuka/git/aws-cdk/node_modules/constructs/lib/construct.js:375:19)
at new Node (/Users/kazuhoshinozuka/git/aws-cdk/node_modules/constructs/lib/construct.js:38:21)
at new Construct (/Users/kazuhoshinozuka/git/aws-cdk/node_modules/constructs/lib/construct.js:426:21)
at new Resource (/Users/kazuhoshinozuka/git/aws-cdk/packages/aws-cdk-lib/core/lib/resource.js:32:9)
at new LayerVersion (/Users/kazuhoshinozuka/git/aws-cdk/packages/aws-cdk-lib/aws-lambda/lib/layers.js:57:9)
at new KubectlV30Layer (/Users/kazuhoshinozuka/git/aws-cdk/node_modules/@aws-cdk/lambda-layer-kubectl-v30/lib/kubectl-layer.js:13:9)
at getClusterVersionConfig (/Users/kazuhoshinozuka/git/aws-cdk/packages/@aws-cdk-testing/framework-integ/test/aws-eks/test/integ-tests-kubernetes-version.js:27:23)
at new EksClusterStack (/Users/kazuhoshinozuka/git/aws-cdk/packages/@aws-cdk-testing/framework-integ/test/aws-eks/test/integ.eks-bootstrap-self-managed-addons.js:19:77)
at Object.<anonymous> (/Users/kazuhoshinozuka/git/aws-cdk/packages/@aws-cdk-testing/framework-integ/test/aws-eks/test/integ.eks-bootstrap-self-managed-addons.js:25:15)
at Module._compile (node:internal/modules/cjs/loader:1546:14)
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.160.0
Framework Version
No response
Node.js Version
v22.9.0
OS
macOS
Language
TypeScript
Language Version
No response
Other information
No response