aws-cdk
aws-cdk copied to clipboard
fix(eks): add tag update support for eks cluster
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:
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
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
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
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 and DESIGN GUIDELINES
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license
AWS CodeBuild CI Report
- CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
- Commit ID: e2da4e9d04fa036058ea992ee58a944807eecf35
- Result: SUCCEEDED
- Build Logs (available for 30 days)
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository
@shikha372 I have made the proposed changes, please take a look
@shikha372 I have made the proposed changes, please take a look
Thank you @mrlikl full coverage with unit tests now :)... wdyt about integ test , just last step of verification to confirm that API is working as expected
Thank you @mrlikl full coverage with unit tests now :)... wdyt about integ test , just last step of verification to confirm that API is working as expected
@shikha372 The updates were manually tested I was unable to convert that flow to an integ test.
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
update
✅ Branch has been successfully updated
AWS CodeBuild CI Report
- CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
- Commit ID: ed6dedffe813e94f3f4ef9f240db017d6f79ffbc
- Result: SUCCEEDED
- Build Logs (available for 30 days)
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).
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.