Skip to content

Commit

Permalink
feat(eks): cluster tagging (#4995) (#18109)
Browse files Browse the repository at this point in the history
Fixes #4995


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
choryuidentify authored Jan 10, 2022
1 parent 912aeda commit 304f5b6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-eks/lib/cluster-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface ClusterResourceProps {
readonly secretsEncryptionKey?: kms.IKey;
readonly onEventLayer?: lambda.ILayerVersion;
readonly clusterHandlerSecurityGroup?: ec2.ISecurityGroup;
readonly tags?: { [key: string]: string };
}

/**
Expand Down Expand Up @@ -89,6 +90,7 @@ export class ClusterResource extends CoreConstruct {
endpointPrivateAccess: props.endpointPrivateAccess,
publicAccessCidrs: props.publicAccessCidrs,
},
tags: props.tags,
},
AssumeRoleArn: this.adminRole.roleArn,

Expand Down
9 changes: 8 additions & 1 deletion packages/@aws-cdk/aws-eks/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -744,13 +744,19 @@ export interface ClusterProps extends ClusterOptions {
*/
readonly defaultCapacityType?: DefaultCapacityType;


/**
* The IAM role to pass to the Kubectl Lambda Handler.
*
* @default - Default Lambda IAM Execution Role
*/
readonly kubectlLambdaRole?: iam.IRole;

/**
* The tags assigned to the EKS cluster
*
* @default - none
*/
readonly tags?: { [key: string]: string };
}

/**
Expand Down Expand Up @@ -1372,6 +1378,7 @@ export class Cluster extends ClusterBase {
subnets: placeClusterHandlerInVpc ? privateSubnets : undefined,
clusterHandlerSecurityGroup: this.clusterHandlerSecurityGroup,
onEventLayer: this.onEventLayer,
tags: props.tags,
});

if (this.endpointAccess._config.privateAccess && privateSubnets.length !== 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,9 @@
],
"endpointPublicAccess": true,
"endpointPrivateAccess": true
},
"tags": {
"foo": "bar"
}
},
"AssumeRoleArn": {
Expand Down
3 changes: 3 additions & 0 deletions packages/@aws-cdk/aws-eks/test/integ.eks-cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class EksClusterStack extends TestStack {
defaultCapacity: 2,
version: eks.KubernetesVersion.V1_21,
secretsEncryptionKey,
tags: {
foo: 'bar',
},
});

this.assertFargateProfile();
Expand Down

0 comments on commit 304f5b6

Please sign in to comment.