fix(autoscaling): AutoScalingGroup requireImdsv2 with launchTemplate or mixedInstancesPolicy throws unclear error#32220
Conversation
aws-cdk-automation
left a comment
There was a problem hiding this comment.
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.
AutoScalingGroup requireImdsv2 with launchTemplate or mixedInstancesPolicy throws unclear error
|
Exemption Request on |
GavinZZ
left a comment
There was a problem hiding this comment.
Just to confirm that the current behaviour is that CFN will throw an error when you set requireImdsv2 with launchTemplate right?
Yes, that will throw an error under current behaviour. It occurs just before cfn synthesis in the Aspect that |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #32220 +/- ##
=======================================
Coverage 78.67% 78.67%
=======================================
Files 107 107
Lines 7237 7237
Branches 1329 1329
=======================================
Hits 5694 5694
Misses 1357 1357
Partials 186 186
Flags with carried forward coverage won't be shown. Click here to find out more.
|
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
|
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). |
|
This pull request has been removed from the queue for the following reason: The pull request can't be updated. You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. If you want to requeue this pull request, you need to post a comment with the text: |
|
@Mergifyio requeue |
❌ Command disallowed due to command restrictions in the Mergify configuration.Details
|
|
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 CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
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). |
|
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). |
|
Comments on closed issues and PRs are hard for our team to see. |
Issue #27586
Fixes #27586
The above issue is already marked as closed, but there is some discussion in it about an additional edge case that this pull request fixes.
Reason for this change
When defining an AutoScalingGroup with both the
requireImdsv2prop and thelaunchTemplateprop, the error message is not clear about the problem.It is not clear from the error that
requireImdsv2should be set in the provided launchTemplate itself rather than the AutoScalingGroup.The error occurs because setting
requireImdsv2on the AutoScalingGroup adds the aspect AutoScalingGroupRequireImdsv2Aspect to it, which expects there to be a child node called either'LaunchConfig'or'LaunchTemplate'depending on a feature flag. This child node is only set in the AutoScalingGroup when neitherlaunchTemplatenormixedInstancesPolicyprops are provided.Description of changes
Add the
requireImdsv2prop to theverifyNoLaunchConfigPropIsGivenmethod, which throws errors when certains props are set at the same time aslaunchTemplateormixedInstancesPolicy.Description of how you validated changes
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license