-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(eks): add tag update support for eks cluster #30123
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed add Clarification Request
to a comment.
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
packages/@aws-cdk/custom-resource-handlers/lib/aws-eks/cluster-resource-handler/cluster.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/custom-resource-handlers/lib/aws-eks/cluster-resource-handler/cluster.ts
Show resolved
Hide resolved
packages/@aws-cdk/custom-resource-handlers/lib/aws-eks/cluster-resource-handler/cluster.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @mrlikl , Thank you for your contribution, left some comments for your inputs.
@shikha372 I have made the proposed changes, please take a look |
packages/@aws-cdk/custom-resource-handlers/test/aws-eks/cluster-resource-provider.test.ts
Show resolved
Hide resolved
packages/@aws-cdk-testing/framework-integ/test/aws-eks/test/integ.eks-cluster-tags.ts
Show resolved
Hide resolved
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
@Mergifyio update |
✅ Branch has been successfully updated |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
### Issue # (if applicable) Closes aws#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*
### Issue # (if applicable) Closes aws#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*
### Issue # (if applicable) Closes aws#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*
Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one. |
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:
TestCase - 1 Update to add one more tag
Logs -
TestCase2 - Add, update and remove at the same time
TestCase - 3 Remove all tags
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license