Skip to content
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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

mrlikl
Copy link
Contributor

@mrlikl mrlikl commented May 9, 2024

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


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added bug This issue is a bug. p2 beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK labels May 9, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team May 9, 2024 12:44
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a 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.

@aws-cdk-automation aws-cdk-automation dismissed their stale review May 9, 2024 13:58

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label May 9, 2024
@mrlikl mrlikl marked this pull request as draft May 9, 2024 19:08
@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label May 9, 2024
@mrlikl mrlikl marked this pull request as ready for review May 9, 2024 19:43
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label May 9, 2024
@shikha372 shikha372 self-assigned this May 9, 2024
Copy link
Contributor

@shikha372 shikha372 left a 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.

@mrlikl mrlikl requested a review from shikha372 May 10, 2024 21:36
@mrlikl
Copy link
Contributor Author

mrlikl commented May 16, 2024

@shikha372 I have made the proposed changes, please take a look

vpc,
...getClusterVersionConfig(this, eks.KubernetesVersion.V1_29),
defaultCapacity: 0,
tags: {
Copy link
Contributor

@shikha372 shikha372 May 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how are we verifying the tag update scenario here ? To explain a bit, was looking for something like once a cluster is created, if we add new props like tag it will trigger the cluster update, using this integ test so that we can verify it is working as expected.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 10f64ea
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mrlikl mrlikl requested a review from shikha372 May 23, 2024 13:43
@shikha372
Copy link
Contributor

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK bug This issue is a bug. p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(eks): EKS tags do not update if edited after initial deploy
3 participants