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

Merged
merged 13 commits into from
May 31, 2024
Merged

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

Copy link
Contributor

mergify bot commented May 29, 2024

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).

@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 29, 2024
Copy link
Contributor

mergify bot commented May 29, 2024

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).

@mergify mergify bot dismissed shikha372’s stale review May 29, 2024 17:53

Pull request has been modified.

@mrlikl mrlikl requested a review from shikha372 May 29, 2024 18:14
@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 29, 2024
@shikha372
Copy link
Contributor

@Mergifyio update

Copy link
Contributor

mergify bot commented May 31, 2024

update

✅ Branch has been successfully updated

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

Copy link
Contributor

mergify bot commented May 31, 2024

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).

@mergify mergify bot merged commit 8c39e81 into aws:main May 31, 2024
10 checks passed
@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 31, 2024
atanaspam pushed a commit to atanaspam/aws-cdk that referenced this pull request Jun 3, 2024
### 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*
vdahlberg pushed a commit to vdahlberg/aws-cdk that referenced this pull request Jun 10, 2024
### 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*
Leo10Gama pushed a commit to Leo10Gama/aws-cdk that referenced this pull request Jun 11, 2024
### 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*
@aws-cdk-automation
Copy link
Collaborator

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.

@aws aws locked as resolved and limited conversation to collaborators Jul 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK bug This issue is a bug. p2
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