Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(eks): add tag update support for eks cluster (#30123)
### Issue # (if applicable) Closes #19388 ### Reason for this change Adding tag/untag for eks cluster post its creation ### Description of changes Added API calls tagResource and untagResource in Cluster resource handler to handle tag changes ### Description of how you validated changes Have tested the changes by first deploying a cluster with below config: ```ts const vpc = ec2.Vpc.fromLookup(stack, 'Vpc', { isDefault: true }); new eks.Cluster(stack, 'Cluster', { vpc, ...getClusterVersionConfig(stack, eks.KubernetesVersion.V1_29), defaultCapacity: 0, tags: { foo: 'bar', }, }); ``` TestCase - 1 Update to add one more tag ```ts new eks.Cluster(stack, 'Cluster', { vpc, ...getClusterVersionConfig(stack, eks.KubernetesVersion.V1_29), defaultCapacity: 0, tags: { foo: 'bar', hello: "world" }, }); ``` Logs - ``` { "updates": { "replaceName": false, "replaceVpc": false, "updateAccess": false, "replaceRole": false, "updateVersion": false, "updateEncryption": false, "updateLogging": false, "updateTags": true } } ``` ``` { clientName: 'EKSClient', commandName: 'TagResourceCommand', input: { resourceArn: 'arn:aws:eks:us-east-1:xxxxx:cluster/Cluster9EE0221C-f0d60e8e0bf14fb5896ade518b5bbc15', tags: { hello: 'world' } }, output: {}, metadata: {} } ``` TestCase2 - Add, update and remove at the same time ```ts new eks.Cluster(stack, 'Cluster', { vpc, ...getClusterVersionConfig(stack, eks.KubernetesVersion.V1_29), defaultCapacity: 0, tags: { hello: 'world1', foobar: 'baz', }, endpointAccess: eks.EndpointAccess.PUBLIC, vpcSubnets: [{ subnetType: ec2.SubnetType.PUBLIC }], }); ``` ``` { clientName: 'EKSClient', commandName: 'TagResourceCommand', input: { resourceArn: 'arn:aws:eks:us-east-1:xxxxx:cluster/Cluster9EE0221C-f0d60e8e0bf14fb5896ade518b5bbc15', tags: { foobar: 'baz', hello: 'world1' } }, output: {}, metadata: {} } ``` ``` { clientName: 'EKSClient', commandName: 'UntagResourceCommand', input: { resourceArn: 'arn:aws:eks:us-east-1:xxxxx:cluster/Cluster9EE0221C-f0d60e8e0bf14fb5896ade518b5bbc15', tagKeys: [ 'foo' ] }, output: {}, metadata: {} } ``` TestCase - 3 Remove all tags ```ts new eks.Cluster(stack, 'Cluster', { vpc, ...getClusterVersionConfig(stack, eks.KubernetesVersion.V1_29), defaultCapacity: 0, endpointAccess: eks.EndpointAccess.PUBLIC, vpcSubnets: [{ subnetType: ec2.SubnetType.PUBLIC }], }); ``` ``` { clientName: 'EKSClient', commandName: 'UntagResourceCommand', input: { resourceArn: 'arn:aws:eks:us-east-1:xxxxx:cluster/Cluster9EE0221C-f0d60e8e0bf14fb5896ade518b5bbc15', tagKeys: [ 'foobar', 'hello' ] }, output: {}, metadata: {} ``` ### 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*
- Loading branch information