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

aws-eks: cluster.addAutoScalingGroupCapacity() does not work as outlined in the docs #33569

Closed
1 task
rpivo opened this issue Feb 24, 2025 · 5 comments
Closed
1 task
Labels
@aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service bug This issue is a bug. closing-soon This issue will automatically close in 4 days unless further comments are made. effort/medium Medium work item – several days of effort p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@rpivo
Copy link

rpivo commented Feb 24, 2025

Describe the bug

When attempting to deploy this:

    cluster.addAutoScalingGroupCapacity(
      'my-self-managed-auto-scaling-group',
      {
        instanceType: new InstanceType('t3.small'),
        minCapacity: 1,
        vpcSubnets: { subnetType: SubnetType.PUBLIC },
      },
    )

I receive this error:

The Launch Configuration creation operation is not available in your account. Use launch templates to create configuration templates for your Auto Scaling groups.

The docs don't outright list the launchTemplate option for addAutoScalingGroupCapacity params (this seems like a separate bug), but it is mentioned in other docs on that page. However, if I try:

    const lt = new LaunchTemplate(this, 'my-node-launch-template', {
      machineImage: new EksOptimizedImage(),
      instanceMetadataTags: true,
      instanceType: InstanceType.of(InstanceClass.T3, InstanceSize.SMALL),
      launchTemplateName: 'my-node-group-launch-template',
      userData: userData,
      role: nodeRole,
      securityGroups: [workerSG],
      versionDescription: 'cool stuff,
    })

    cluster.addAutoScalingGroupCapacity(
      'my-self-managed-auto-scaling-group',
      {
        launchTemplate: lt,
      },
    )

I receive this error:

TypeError: Cannot read properties of undefined (reading 'toString')

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

unknown

Expected Behavior

N/A

Current Behavior

N/A

Reproduction Steps

N/A

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.180.0

Framework Version

No response

Node.js Version

23

OS

Linux

Language

TypeScript

Language Version

No response

Other information

No response

@rpivo rpivo added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 24, 2025
@github-actions github-actions bot added the @aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service label Feb 24, 2025
@rpivo
Copy link
Author

rpivo commented Feb 24, 2025

I should mention that this:

    cluster.addAutoScalingGroupCapacity(
      'my-self-managed-auto-scaling-group',
      {
        instanceType: new InstanceType('t3.small'),
        minCapacity: 1,
        vpcSubnets: { subnetType: SubnetType.PUBLIC },
      },
    )

Is from the documentation here: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_eks-readme.html#self-managed-nodes

@pahud pahud self-assigned this Feb 24, 2025
@pahud
Copy link
Contributor

pahud commented Feb 24, 2025

addAutoScalingGroupCapacity() essentially creates the ASG like this:

const asg = new autoscaling.AutoScalingGroup(this, id, {
...options,
vpc: this.vpc,
machineImage: options.machineImageType === MachineImageType.BOTTLEROCKET ?
new BottleRocketImage({
kubernetesVersion: this.version.version,
}) :
new EksOptimizedImage({
nodeType: nodeTypeForInstanceType(options.instanceType),
cpuArch: cpuArchForInstanceType(options.instanceType),
kubernetesVersion: this.version.version,
}),
});

and AutoScalingGroup() requires this to enable launchTemplate which is missing in addAutoScalingGroupCapacity()

if (props.launchTemplate || props.mixedInstancesPolicy) {

However, when AUTOSCALING_GENERATE_LAUNCH_TEMPLATE feat flag is enabled, a default launch template should be created for the ASG.

if (FeatureFlags.of(this).isEnabled(AUTOSCALING_GENERATE_LAUNCH_TEMPLATE)) {

Can you check your cdk.json and see if this feat flag is enabled? If not, please enable it and see if it works for you?

 % grep "generateLaunchTemplateInsteadOfLaunchConfig" cdk.json 
    "@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true,

@pahud pahud added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Feb 24, 2025
@pahud pahud removed their assignment Feb 24, 2025
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Feb 26, 2025
@rpivo
Copy link
Author

rpivo commented Feb 26, 2025

Hey @pahud

@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true

That was exactly what I needed. Thanks!

@rpivo rpivo closed this as completed Feb 26, 2025
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service bug This issue is a bug. closing-soon This issue will automatically close in 4 days unless further comments are made. effort/medium Medium work item – several days of effort p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

2 participants