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-autoscaling: Use launch templates instead of deprecated launch configurations #23165

Closed
2 tasks
kichik opened this issue Nov 29, 2022 · 18 comments · Fixed by #25910
Closed
2 tasks

aws-autoscaling: Use launch templates instead of deprecated launch configurations #23165

kichik opened this issue Nov 29, 2022 · 18 comments · Fixed by #25910
Assignees
Labels
@aws-cdk/aws-autoscaling Related to Amazon EC2 Auto Scaling breaking-change This issue requires a breaking change to remediate. effort/large Large work item – several weeks of effort feature-request A feature should be added or improved. in-progress This issue is being actively worked on. p1

Comments

@kichik
Copy link

kichik commented Nov 29, 2022

Describe the feature

We just got an email from AWS saying launch configurations are deprecated. New accounts won't allow creating launch configurations after December 31st, 2023. No new features or instance types will be available after December 31st, 2022.

Unless given a launch template, AutoScalingGroup always creates a deprecated launch configuration.

Use Case

Deploying existing CDK apps that use AutoScalingGroup without manually specifying a manually created launch template would fail soon. Using new instance types will be impossible without first manually creating a launch template.

Proposed Solution

It would be great if AutoScalingGroup could start creating launch templates instead of launch configurations.

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.52.0

Environment details (OS name and version, etc.)

N/A

@kichik kichik added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Nov 29, 2022
@github-actions github-actions bot added the @aws-cdk/aws-autoscaling Related to Amazon EC2 Auto Scaling label Nov 29, 2022
@peterwoodworth peterwoodworth added p1 effort/large Large work item – several weeks of effort breaking-change This issue requires a breaking change to remediate. and removed needs-triage This issue or PR still needs to be triaged. labels Nov 29, 2022
@peterwoodworth
Copy link
Contributor

Thanks for the request, this is something we should definitely have on our radar especially as the deprecation date nears at the end of next year

@kvndng-amz
Copy link

kvndng-amz commented Nov 30, 2022

More information on timelines from the email received:

The following are key dates for launch configuration deprecation:

December 31, 2022
- No new EC2 features or new EC2 instance types will be added to launch configurations after this date.

March 31, 2023
- New accounts created after this date will not be able to create new launch configurations via the console. API and CLI access will remain available to support customers with automation use cases.

December 31, 2023
- New accounts created after this date will not be able to create new launch configurations.

This sounds like a fairly sizable change, but it would be nice if any functionality being deprecated could be replaced with the launch template equivalent before the respective date of deprecation.

One use case in particular is providing user commands with CloudFormationInit. The applyCloudFormationInit() method by default attaches the cfn-init and cfn-signal commands to the launch configuration's UserData, but with this upcoming launch configuration deprecation that'd need to be changed to use launch templates instead. Would this be tied in with this feature request, or do changes to specific methods like this require separate GH feature requests?

@simonrouse9461
Copy link

simonrouse9461 commented Dec 27, 2022

@peterwoodworth Any update on this? Our team also received an email notification about the launch configuration deprecation. However, we are having a hard time migrating because the LaunchTemplate construct doesn't support CloudFormationInit. We've considered one alternative, which is using CfnLaunchTemplate to manually attach metadata and then manually configure userData, but that will make the code way more complicated and error-prone.

@azatoth
Copy link
Contributor

azatoth commented Mar 27, 2023

@peterwoodworth Any progress on this? We are nearing the second key date and there hasn't been any progress on the issue. What can we do to help?

@mbp
Copy link

mbp commented Apr 28, 2023

We have the same problem - not able to migrate to launch templates because it is not possible to attach CloudFormationInit to LaunchTemlpate.

@hervenivon
Copy link

We just received a reminder deprecation notice. "[Reminder] Ending Amazon EC2 Launch Configurations Console support for new accounts"

I would love to hear an official voice.

Best,

@comcalvi comcalvi removed their assignment May 25, 2023
@colifran colifran self-assigned this May 31, 2023
@colifran colifran added the in-progress This issue is being actively worked on. label Jun 1, 2023
@colifran
Copy link
Contributor

colifran commented Jun 1, 2023

Hi everyone. I wanted to comment to say that this is in progress and is currently being worked on.

@colifran
Copy link
Contributor

colifran commented Jun 8, 2023

@mbp @simonrouse9461 @kvndng-amz I've been looking into the CloudFormationInit and LaunchTemplate issues and from what I can tell, it looks like the way to do this would be to not add the CloudFormationInit to the LaunchTemplate and instead to continue adding a CloudFormationInit as part of the AutoScalingGroup similar to if you wanted to use a CloudFormationInit with a launch configuration. Have any of you attempted this with success? I want to verify that I'm not overlooking something.

@mbp
Copy link

mbp commented Jun 12, 2023

@colifran

Sorry for late response.

I tried with the following code:

    const launchTemplate = new ec2.LaunchTemplate(this, "LaunchTemplate", {
      role: launchRole,
      requireImdsv2: true,
      securityGroup: launchTemplateSecurityGroup,
      instanceType: instanceType,
      machineImage: machineImage,
      blockDevices: [
        {
          deviceName: "/dev/sda1",
          volume: autoscaling.BlockDeviceVolume.ebs(50, {
            encrypted: true,
          }),
        },
      ],
    });
    
    const appAutoscalingGroup = new autoscaling.AutoScalingGroup(this, "ASG", {
      vpc,
      launchTemplate: launchTemplate,
      allowAllOutbound: true,
      maxCapacity: 2,
      minCapacity: 1,
      init: init,
    });    

As you can see - I pass init to the AutoScalingGroup.

But it provides the following error: The provided launch template does not expose its user data.

Because of this error - I tried to move cloudformation init to LaunchTemplate (without success).

@abalasky-chronos
Copy link

Hi any update on this? Currently AutoScalingGroup with CDK is still using Launch Config instead of Launch template? At least could you point me to usage for configuring my own Launch Template?

@colifran
Copy link
Contributor

@abalasky-chronos I'm close to having a PR ready for review. I have the code done and am just working on getting 6 or so integ tests updated. I should have a PR in soon. In the meantime, this mapping may be able to help you configure an equivalent launch template based on launch configuration properties - https://docs.aws.amazon.com/autoscaling/ec2/userguide/migrate-launch-configurations-with-cloudformation.html#launch-configuration-mapping-reference.

@colifran
Copy link
Contributor

@mbp no worries and thanks for your response. I think the issue here is that if no explicit user data is provided with the launch template, then when we try to get the user data to pass to the cfn-init configuration method when creating the auto scaling group an error is thrown since user data would be undefined. We added a feature flag to configure a launch template with default user data based on the provided machine image though. If that is set to true that error should go away. That said, I'm working on addressing this in the launch configuration deprecation since I can see how this would cause confusion.

@abalasky-chronos
Copy link

@colifran Thank you so much! Appreciate the prompt response.

@SamuelLordMO
Copy link

Slightly tangential to this issue, but the (python) docs suggest this is already supported, but actually the launch_template contructor parameter isn't present. Will this being released effectively solve the discrepancy between the docs and python or should I open a new bug report?

Example output trying to use launch_template:

line 19, in build
    ...
File "<filepath>", line 73, in __init__
    asg = autoscaling.AutoScalingGroup(self, f"{stack_config.stack_name_prefix}-AutoScalingGroup",
File "\.venv\lib\site-packages\jsii\_runtime.py", line 86, in __call__
    inst = super().__call__(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'launch_template'

@colifran
Copy link
Contributor

@SamuelLordMO this seems like it would be a separate issue. The deprecation of launch configurations will result in the auto scaling group automatically generating a launch template from properties that were previously used to create a launch configuration. So, your new options will be provide a launch template, provide a mixed instances policy, or provide properties that will be used to automatically generate a launch template for you. Providing an explicit launch template is already supported, so this could be a bug. Could you provide a snippet of the code you're using so that we could try to reproduce the issue on our end?

@SamuelLordMO
Copy link

In putting together a minimal repro I found that my issue was actually an old venv that was out of date being used for synth, but not for docs/autocomplete etc. So I won't raise a bug! Thanks for your quick response, though :)

@mergify mergify bot closed this as completed in #25910 Jul 6, 2023
mergify bot pushed a commit that referenced this issue Jul 6, 2023
…g) (#25910)

This PR focuses on supporting the deprecation of launch configurations when creating an auto scaling group. All new accounts created after December 31, 2023 will no longer be able to create launch configurations. An equivalent launch template will now be created by the AutoScalingGroup construct instead of a launch configuration.

Closes #23165

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

github-actions bot commented Jul 6, 2023

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

tmokmss pushed a commit to tmokmss/aws-cdk that referenced this issue Jul 9, 2023
…g) (aws#25910)

This PR focuses on supporting the deprecation of launch configurations when creating an auto scaling group. All new accounts created after December 31, 2023 will no longer be able to create launch configurations. An equivalent launch template will now be created by the AutoScalingGroup construct instead of a launch configuration.

Closes aws#23165

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
bmoffatt pushed a commit to bmoffatt/aws-cdk that referenced this issue Jul 29, 2023
…g) (aws#25910)

This PR focuses on supporting the deprecation of launch configurations when creating an auto scaling group. All new accounts created after December 31, 2023 will no longer be able to create launch configurations. An equivalent launch template will now be created by the AutoScalingGroup construct instead of a launch configuration.

Closes aws#23165

----

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

Slightly tangential to this issue, but the (python) docs suggest this is already supported, but actually the launch_template contructor parameter isn't present. Will this being released effectively solve the discrepancy between the docs and python or should I open a new bug report?

Example output trying to use launch_template:

line 19, in build
    ...
File "<filepath>", line 73, in __init__
    asg = autoscaling.AutoScalingGroup(self, f"{stack_config.stack_name_prefix}-AutoScalingGroup",
File "\.venv\lib\site-packages\jsii\_runtime.py", line 86, in __call__
    inst = super().__call__(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'launch_template'

Hi am facing same issue, can you please help me with your hack??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-autoscaling Related to Amazon EC2 Auto Scaling breaking-change This issue requires a breaking change to remediate. effort/large Large work item – several weeks of effort feature-request A feature should be added or improved. in-progress This issue is being actively worked on. p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.