Skip to content

feat(eks): cluster tagging (#4995)#18109

Merged
mergify[bot] merged 2 commits intoaws:masterfrom
choryuidentify:dev-eks-cluster-tag
Jan 10, 2022
Merged

feat(eks): cluster tagging (#4995)#18109
mergify[bot] merged 2 commits intoaws:masterfrom
choryuidentify:dev-eks-cluster-tag

Conversation

@choryuidentify
Copy link
Copy Markdown
Contributor

Fixes #4995


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

@gitpod-io
Copy link
Copy Markdown

gitpod-io bot commented Dec 21, 2021

@github-actions github-actions bot added the @aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service label Dec 21, 2021
@otaviomacedo otaviomacedo added the pr-linter/exempt-readme The PR linter will not require README changes label Jan 10, 2022
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Jan 10, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: a789023
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@mergify mergify bot merged commit 304f5b6 into aws:master Jan 10, 2022
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Jan 10, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@robertd
Copy link
Copy Markdown
Contributor

robertd commented Jan 18, 2022

@choryuidentify This doesn't really apply tags on the cluster itself... Also, I'm not seeing tags property on the constructor for the Fargate cluster.

Edit: I'm using 2.8.0. Let me check if this functionality got ported to cdk 2.x really quick.

Edit 2: Yep... it did in 2.7.0.

image

image

@choryuidentify
Copy link
Copy Markdown
Contributor Author

choryuidentify commented Jan 18, 2022

@choryuidentify This doesn't really apply tags on the cluster itself... Also, I'm not seeing tags property on the constructor for the Fargate cluster.

Edit: I'm using 2.8.0. Let me check if this functionality got ported to cdk 2.x really quick.

Edit 2: Yep... it did in 2.7.0.

I tested it now with aws-cdk 2.8.0 and @aws-cdk/aws-eks 1.139.0

new eks.Cluster(this, 'test-cluster', {
  version: KubernetesVersion.V1_21,
  tags: {
    "foo": "bar"
  }
})

...and looks good (I didn't deploy this but synth it)

I can see the 'tags' on cluster constructor

  testcluster29C11904:
    Type: Custom::AWSCDK-EKS-Cluster
    Properties:
      ServiceToken:
        Fn::GetAtt:
          - awscdkawseksClusterResourceProviderNestedStackawscdkawseksClusterResourceProviderNestedStackResource9827C454
          - Outputs.SampleStackawscdkawseksClusterResourceProviderframeworkonEvent06FEB728Arn
      Config:
        version: "1.21"
        roleArn:
          Fn::GetAtt:
            - testclusterRoleF0736E25
            - Arn
        resourcesVpcConfig:
          subnetIds:
            - Ref: testclusterDefaultVpcPublicSubnet1Subnet0CB1FE0A
            - Ref: testclusterDefaultVpcPublicSubnet2Subnet2D94C923
            - Ref: testclusterDefaultVpcPrivateSubnet1Subnet570845A0
            - Ref: testclusterDefaultVpcPrivateSubnet2Subnet7AFA8EC9
          securityGroupIds:
            - Fn::GetAtt:
                - testclusterControlPlaneSecurityGroupC4E3812B
                - GroupId
          endpointPublicAccess: true
          endpointPrivateAccess: true
        tags:
          foo: bar

Did you upgrade @aws-cdk/aws-eks of the project?

@robertd
Copy link
Copy Markdown
Contributor

robertd commented Jan 18, 2022

@choryuidentify I'm using cdk 2.8.0 ... and I'm seeing tags being propagated to Custom::AWSCDK-EKS-Cluster. Given that tags are supported on AWS::EKS::Cluster... something tells me that the custom resource doesn't propagate them properly.

image

@choryuidentify
Copy link
Copy Markdown
Contributor Author

choryuidentify commented Jan 19, 2022

@robertd

I tested it using CDK 2.8.0. It deployed with tags successfully.

**EDIT: sorry, I misunderstood. CDK 2 was completely changed dependencies path.
No need to install / upgrade @aws-cdk/aws-eks module because it's CDK 1. remove wrong texts.

I don't get it. It looks not an issue of this patch.
Maybe reinstall cdk / recreate project / bootstrap cdk into your account again can be help you.

package.json

{
  "name": "testcdk",
  "version": "0.1.0",
  "bin": {
    "testcdk": "bin/testcdk.js"
  },
  "scripts": {
    "build": "tsc",
    "watch": "tsc -w",
    "test": "jest",
    "cdk": "cdk"
  },
  "devDependencies": {
    "@types/jest": "^26.0.10",
    "@types/node": "10.17.27",
    "aws-cdk": "2.8.0",
    "jest": "^26.4.2",
    "ts-jest": "^26.2.0",
    "ts-node": "^9.0.0",
    "typescript": "~3.9.7"
  },
  "dependencies": {
    "aws-cdk-lib": "2.8.0",
    "constructs": "^10.0.0"
  }
}

testcdk-stack.ts

import { Stack, StackProps } from 'aws-cdk-lib';
import * as eks from 'aws-cdk-lib/aws-eks';
import { KubernetesVersion } from 'aws-cdk-lib/aws-eks';
import { Construct } from 'constructs';

export class TestcdkStack extends Stack {
  constructor(scope: Construct, id: string, props?: StackProps) {
    super(scope, id, props);

    new eks.Cluster(this, "testCluster", {
      version: KubernetesVersion.V1_21,
      defaultCapacity: 0,
      tags: {
        "foo": "bar",
        "and": "more",
        'other': 'tags'
      }
    })
  }
}

Result

@robertd
Copy link
Copy Markdown
Contributor

robertd commented Jan 19, 2022 via email

@choryuidentify
Copy link
Copy Markdown
Contributor Author

@robertd Sorry, Please check my reply again in GitHub. I edited my message several times, and I removed wrong suggestion.

@robertd
Copy link
Copy Markdown
Contributor

robertd commented Jan 19, 2022 via email

@robertd
Copy link
Copy Markdown
Contributor

robertd commented Jan 19, 2022

@choryuidentify Must be something on my end, but I'm using 2.8.0 w/ projen. Thanks for your help btw. image

@robertd
Copy link
Copy Markdown
Contributor

robertd commented Jan 19, 2022

@choryuidentify tags started propagating after full cleanup... something got stale on my end. Thanks for your help again.
image

@choryuidentify
Copy link
Copy Markdown
Contributor Author

Nice!

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
Fixes aws#4995


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

@aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service pr-linter/exempt-readme The PR linter will not require README changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[aws-eks] Cluster Tags

4 participants