Closed kirksaunders closed 9 months ago
Yes we welcome pull requests from the community for this feature. Before that, as CFN has supported it, we can use escape hatches to add property overrides as a workaround.
I will take this.
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.
@go-to-k @pahud Is there a way to set the "Launch Before Terminate" setting via CDK? I looked through the attached PR and it only modifies the Min and Max health percentage.
@abhishek-parative
Yes, the "Launch Before Terminate" policy is equal to a setting with the Min = 100% (and the Max > 100%). So this setting allows the policy to be used in the CDK.
Describe the feature
AWS EC2 AutoScaling just added a new way to manage the replacement of instances, called the Instance Maintenance Policy (launch announcement). The policy allows you to control the percentage of instances above and below your desired capacity to allow during replacements/updates. And in particular, this policy now allows a "Launch-Before-Terminate" strategy, to perform replacements without impacting ASG healthy capacity.
Use Case
My team wants to use the new "Launch-Before-Terminate" feature to more safely update our ASGs. In particular, we have a few fleets with very few instances. To safely update now, we must overscale our fleets to maintain enough capacity for serving requests. With this new feature, we can keep our fleets descaled, and use the "Launch-Before-Terminate" feature to safely update.
Proposed Solution
Add a new property to the
AutoScaling
construct that allows you to set the instance maintenance policy.Other Information
References for the policy: [1] https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-autoscaling-autoscalinggroup-instancemaintenancepolicy.html [2] https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-autoscaling-autoscalinggroup.html [3] https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-instance-maintenance-policy.html [4] https://docs.aws.amazon.com/autoscaling/ec2/userguide/set-instance-maintenance-policy-on-group.html [5] https://aws.amazon.com/blogs/compute/introducing-instance-maintenance-policy-for-amazon-ec2-auto-scaling/
Acknowledgements
CDK version used
v2.109.0
Environment details (OS name and version, etc.)
Amazon Linux 2