简体   繁体   中英

How can I edit Nodegroup in AWS EKS from AWS CDK

I use AWS CDK to create eks cluster then use addNodegroupCapacity to add nodegroup.

    const myNodeGroup = cluster.addNodegroupCapacity('my-node-group', {
      nodegroupName: 'my-node-group',
      instanceTypes: [
        new ec2.InstanceType('t3a.small'), 
      ],
      minSize: 1,
      desiredSize: 1,
      maxSize: 1,
      diskSize: 10,
      capacityType: eks.CapacityType.SPOT,
      amiType: eks.NodegroupAmiType.AL2_X86_64,
      subnets: { subnetType: ec2.SubnetType.PUBLIC },
    })

I want to change subnet to

    subnets: { availabilityZones: ['ap-southeast-1a'] }

When I made change in CDK I got an error

    Resource handler returned message: "NodeGroup already exists with name my-node-group and cluster name  (Service: Eks, Status Code: 409, Request ID: {Request ID})" (RequestToken: {RequestToken}, HandlerErrorCode: AlreadyExists)

How can I edit this nodegroup from AWS CDK or I have to delete and recreate it?

Changing the subnet is a replacement operation , which means the NodeGroup will be destroyed and another created. However, your explicit nodegroupName is interfering with this CloudFormation process. For this reason it's best practice to use generated resource names, not physical names .

Delete the resource manually. Remove the nodegroupName prop to avoid this problem in the future.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM