Skip to content

Commit 304f5b6

Browse files
feat(eks): cluster tagging (#4995) (#18109)
Fixes #4995 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 912aeda commit 304f5b6

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

packages/@aws-cdk/aws-eks/lib/cluster-resource.ts

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export interface ClusterResourceProps {
2828
readonly secretsEncryptionKey?: kms.IKey;
2929
readonly onEventLayer?: lambda.ILayerVersion;
3030
readonly clusterHandlerSecurityGroup?: ec2.ISecurityGroup;
31+
readonly tags?: { [key: string]: string };
3132
}
3233

3334
/**
@@ -89,6 +90,7 @@ export class ClusterResource extends CoreConstruct {
8990
endpointPrivateAccess: props.endpointPrivateAccess,
9091
publicAccessCidrs: props.publicAccessCidrs,
9192
},
93+
tags: props.tags,
9294
},
9395
AssumeRoleArn: this.adminRole.roleArn,
9496

packages/@aws-cdk/aws-eks/lib/cluster.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -744,13 +744,19 @@ export interface ClusterProps extends ClusterOptions {
744744
*/
745745
readonly defaultCapacityType?: DefaultCapacityType;
746746

747-
748747
/**
749748
* The IAM role to pass to the Kubectl Lambda Handler.
750749
*
751750
* @default - Default Lambda IAM Execution Role
752751
*/
753752
readonly kubectlLambdaRole?: iam.IRole;
753+
754+
/**
755+
* The tags assigned to the EKS cluster
756+
*
757+
* @default - none
758+
*/
759+
readonly tags?: { [key: string]: string };
754760
}
755761

756762
/**
@@ -1372,6 +1378,7 @@ export class Cluster extends ClusterBase {
13721378
subnets: placeClusterHandlerInVpc ? privateSubnets : undefined,
13731379
clusterHandlerSecurityGroup: this.clusterHandlerSecurityGroup,
13741380
onEventLayer: this.onEventLayer,
1381+
tags: props.tags,
13751382
});
13761383

13771384
if (this.endpointAccess._config.privateAccess && privateSubnets.length !== 0) {

packages/@aws-cdk/aws-eks/test/integ.eks-cluster.expected.json

+3
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,9 @@
951951
],
952952
"endpointPublicAccess": true,
953953
"endpointPrivateAccess": true
954+
},
955+
"tags": {
956+
"foo": "bar"
954957
}
955958
},
956959
"AssumeRoleArn": {

packages/@aws-cdk/aws-eks/test/integ.eks-cluster.ts

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ class EksClusterStack extends TestStack {
3838
defaultCapacity: 2,
3939
version: eks.KubernetesVersion.V1_21,
4040
secretsEncryptionKey,
41+
tags: {
42+
foo: 'bar',
43+
},
4144
});
4245

4346
this.assertFargateProfile();

0 commit comments

Comments
 (0)