Skip to content

Commit 19710cc

Browse files
committed
simplify mixed instance ASG support
Based on my thoughts at [1] * drop SpotPrice param, use OnDemandPercentage instead (with default to 100%) * drop SpotAllocationStrategy and OnDemandBaseCapacity, use sensible defaults * drop InstanceType1, use the existing InstanceType param * always used a mixed instance ASG, even when only a single instance type is requested. For simplicity of the template and resulting resources. [1] #651 (comment)
1 parent 283df73 commit 19710cc

File tree

1 file changed

+31
-78
lines changed

1 file changed

+31
-78
lines changed

templates/aws-stack.yml

Lines changed: 31 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ Metadata:
3939
- ImageId
4040
- ImageIdParameter
4141
- InstanceType
42+
- InstanceType2
43+
- InstanceType3
44+
- InstanceType4
4245
- AgentsPerInstance
4346
- KeyName
44-
- SpotPrice
4547
- SecretsBucket
4648
- ArtifactsBucket
4749
- AuthorizedUsersUrl
@@ -57,13 +59,7 @@ Metadata:
5759
Parameters:
5860
- MinSize
5961
- MaxSize
60-
- SpotAllocationStrategy
61-
- OnDemandBaseCapacity
62-
- OnDemandPercentageAboveBaseCapacity
63-
- InstanceType1
64-
- InstanceType2
65-
- InstanceType3
66-
- InstanceType4
62+
- OnDemandPercentage
6763
- ScaleOutFactor
6864
- ScaleInIdlePeriod
6965
- ScaleOutForWaitingJobs
@@ -216,11 +212,6 @@ Parameters:
216212
Default: t3.large
217213
MinLength: 1
218214

219-
SpotPrice:
220-
Description: Maximum Spot bid price to use for the instances. 0 allows you to specify mixed instances (a combination of On-Demand and Spot Instances across multiple instances types)
221-
Type: String
222-
Default: 0
223-
224215
MaxSize:
225216
Description: Maximum number of instances
226217
Type: Number
@@ -232,11 +223,6 @@ Parameters:
232223
Type: Number
233224
Default: 0
234225

235-
InstanceType1:
236-
Description: The primary instance type to use when requesting mixed instance types.
237-
Type: String
238-
Default: ""
239-
240226
InstanceType2:
241227
Description: The secondary instance type to use when requesting mixed instances. Omit this parmameter to only request 1 instance type.
242228
Type: String
@@ -252,23 +238,12 @@ Parameters:
252238
Type: String
253239
Default: ""
254240

255-
SpotAllocationStrategy:
256-
Description: Indicates how to allocate Spot capacity across Spot pools.
257-
AllowedValues:
258-
- capacity-optimized
259-
- lowest-price
260-
Type: String
261-
Default: capacity-optimized
262-
263-
OnDemandBaseCapacity:
264-
Description: Minimum number of instances in the ASG's initial capacity that must be fulfilled by On-Demand instances.
265-
Type: Number
266-
Default: 0
267-
268-
OnDemandPercentageAboveBaseCapacity:
269-
Description: Percentage of On-Demand Instances for additional capacity beyond the optional On-Demand base amount.
241+
OnDemandPercentage:
242+
Description: Percentage of total instances that should launch as OnDemand. Reduce this to use some Spot Instances when they're available.
270243
Type: Number
271-
Default: 40
244+
Default: 100
245+
MinValue: 0
246+
MaxValue: 100
272247

273248
ScaleOutFactor:
274249
Description: A decimal factor to apply to scale out changes to speed up or slow down scale-out
@@ -456,8 +431,6 @@ Outputs:
456431
Name: !Sub '${AWS::StackName}-InstanceRoleName'
457432

458433
Conditions:
459-
UseSpotInstances:
460-
!Not [ !Equals [ !Ref SpotPrice, 0 ] ]
461434

462435
CreateVpcResources:
463436
!Equals [ !Ref VpcId, "" ]
@@ -491,9 +464,6 @@ Conditions:
491464
UseDefaultRootVolumeName:
492465
!Equals [ !Ref RootVolumeName, "" ]
493466

494-
UseInstanceType1:
495-
!Not [ !Equals [ !Ref InstanceType1, ""] ]
496-
497467
UseInstanceType2:
498468
!Not [ !Equals [ !Ref InstanceType2, ""] ]
499469

@@ -861,12 +831,6 @@ Resources:
861831
IamInstanceProfile:
862832
Arn: !GetAtt "IAMInstanceProfile.Arn"
863833
InstanceType: !Ref InstanceType
864-
InstanceMarketOptions: !If
865-
- UseSpotInstances
866-
- MarketType: spot
867-
SpotOptions:
868-
MaxPrice: !Ref SpotPrice
869-
- !Ref "AWS::NoValue"
870834
ImageId: !If [ HasImageId, !Ref ImageId, !If [ HasImageIdParameter, !GetAtt ImageIdParameterStack.Outputs.ImageId, !FindInMap [ AWSRegion2AMI, !Ref 'AWS::Region', !Ref InstanceOperatingSystem ] ] ]
871835
BlockDeviceMappings:
872836
- DeviceName: !If [ UseDefaultRootVolumeName, !If [ UseWindowsAgents, /dev/sda1, /dev/xvda ], !Ref RootVolumeName ]
@@ -971,39 +935,28 @@ Resources:
971935
Type: AWS::AutoScaling::AutoScalingGroup
972936
Properties:
973937
VPCZoneIdentifier: !If [ "CreateVpcResources", [ !Ref Subnet0, !Ref Subnet1 ], !Ref Subnets ]
974-
MixedInstancesPolicy: !If
975-
- UseSpotInstances
976-
- !Ref "AWS::NoValue"
977-
- InstancesDistribution:
978-
OnDemandBaseCapacity: !Ref OnDemandBaseCapacity
979-
OnDemandPercentageAboveBaseCapacity: !Ref OnDemandPercentageAboveBaseCapacity
980-
SpotAllocationStrategy: !Ref SpotAllocationStrategy
981-
LaunchTemplate:
982-
LaunchTemplateSpecification:
983-
LaunchTemplateId: !Ref AgentLaunchTemplate
984-
Version: !GetAtt "AgentLaunchTemplate.LatestVersionNumber"
985-
Overrides:
986-
- InstanceType: !If
987-
- UseInstanceType1
988-
- !Ref InstanceType1
989-
- !Ref InstanceType
990-
- InstanceType: !If
991-
- UseInstanceType2
992-
- !Ref InstanceType2
993-
- !Ref "AWS::NoValue"
994-
- InstanceType: !If
995-
- UseInstanceType3
996-
- !Ref InstanceType3
997-
- !Ref "AWS::NoValue"
998-
- InstanceType: !If
999-
- UseInstanceType4
1000-
- !Ref InstanceType4
1001-
- !Ref "AWS::NoValue"
1002-
LaunchTemplate: !If
1003-
- UseSpotInstances
1004-
- LaunchTemplateId: !Ref AgentLaunchTemplate
1005-
Version: !GetAtt "AgentLaunchTemplate.LatestVersionNumber"
1006-
- !Ref "AWS::NoValue"
938+
MixedInstancesPolicy:
939+
InstancesDistribution:
940+
OnDemandPercentageAboveBaseCapacity: !Ref OnDemandPercentage
941+
SpotAllocationStrategy: capacity-optimized
942+
LaunchTemplate:
943+
LaunchTemplateSpecification:
944+
LaunchTemplateId: !Ref AgentLaunchTemplate
945+
Version: !GetAtt "AgentLaunchTemplate.LatestVersionNumber"
946+
Overrides:
947+
- InstanceType: !Ref InstanceType
948+
- InstanceType: !If
949+
- UseInstanceType2
950+
- !Ref InstanceType2
951+
- !Ref "AWS::NoValue"
952+
- InstanceType: !If
953+
- UseInstanceType3
954+
- !Ref InstanceType3
955+
- !Ref "AWS::NoValue"
956+
- InstanceType: !If
957+
- UseInstanceType4
958+
- !Ref InstanceType4
959+
- !Ref "AWS::NoValue"
1007960
MinSize: !Ref MinSize
1008961
MaxSize: !Ref MaxSize
1009962
Cooldown: 0

0 commit comments

Comments
 (0)