Mixed Spot Fleets and Launch Configurations vs Launch Templates #6714
Labels
@aws-cdk/aws-autoscaling
Related to Amazon EC2 Auto Scaling
feature-request
A feature should be added or improved.
I need to create a mixed spot instance fleet, that is, a spot instance fleet which consists of multiple instance types. Currently in CDK, there is no L2 way of doing this. The AutoscalingGroup L2 construct doesn't provide a parameter to control spot instances except for the
spotPrice
optional param, and it also creates – behind the scenes, without any user control – a launch configuration (which has no CDK exported L2 counterpart, only an L1CfnLaunchConfiguration
). There is no way to make ASGs use Launch Templates; they always create aCfnLaunchConfiguration
in the background, even though current best practice since 2017 is to use Launch Templates. You have no choice; neither do you have any control over the launch configuration resource created by the CDK. This is a problem since launch configurations and launch templates are mutually exclusive, and mixed fleets require the use of launch templates.In a situation like this, I'd go for the L1 construct escape hatch, casting L2 constructs into L1 constructs as necessary. What I'd do is basically to cast the
AutoscalingGroup
to aCfnAutoscalingGroup
, null out or delete itsLaunchConfiguration
L1 parameter, and then use theMixedInstancesPolicy
param to supply aMixedInstancesPolicyProperty
instead.However, it's not clear whether L2 logic such as
scaleToTrackMetric
and others such asaddUserData
still will work, or if these have to be added manually on the L1 level to the ASG or to the new L1CfnLaunchTemplate
.The question is whether it might be better to skip all the "cleverness" added by the CDK
AutoscalingGroup
L2 construct and build everything using the L1 ones, since the CDK makes too many assumptions for the L2 construct to be useful outside a fairly narrow range of use cases. Another option is to suggest that the CDK switches to launch templates internally, which should be easy since the autogeneratedCfnLaunchConfiguration
resource isn't exposed in any way.I'm aware of cf #3077 and #1403
This is a 🚀 Feature Request
The text was updated successfully, but these errors were encountered: