Skip to content

Commit e2b54ee

Browse files
committed
restore the SpotPrice parameter, but deprecate it
In the next major release (v6?) we'd like to remove the SpotPrice parameter - customers can use the OnDemandPercentage parameter to opt into using spot instances with a price cap equal to the OnDemand price. However, in the 5.x series we don't want breaking changes like removing a param. This commit restores SpotPrice and keeps the same semantics: * if it's set to 0 then we use OnDemandPercentage to decide if spot instances are used. OnDemandPercentage defaults to 100%, so stacks with a SpotPrice of 0 will continue to have 100% OnDeman instances when they upgrade * if it's set to >0 then we ignore OnDemandPercentage and force the stack to be 100% spot. When we're prepping for the v6 release we can remove the SpotPrice parameter and use only the OnDemandPercentage parameter to decide if spot instances are used. I've also expands the SpotPrice parameter description. Partly to clarify how it has always worked, partly to indicate it's deprecated.
1 parent 4ed9bb4 commit e2b54ee

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

templates/aws-stack.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Metadata:
4141
- InstanceType
4242
- AgentsPerInstance
4343
- KeyName
44+
- SpotPrice
4445
- SecretsBucket
4546
- ArtifactsBucket
4647
- AuthorizedUsersUrl
@@ -211,6 +212,11 @@ Parameters:
211212
AllowedPattern: "^[\\w\\.]+(,[\\w\\.]*){0,3}$"
212213
ConstraintDescription: "must contain 1-4 instance types separated by commas. No space before/after the comma."
213214

215+
SpotPrice:
216+
Description: Maximum spot price to use for the instances, in instance cost per hour. Values >0 will result in 100% of instances being spot. 0 means only use normal (non-spot) instances. This parameter is deprecated - we recommend setting to 0 and using OnDemandPercentage to opt into spot instances.
217+
Type: String
218+
Default: 0
219+
214220
MaxSize:
215221
Description: Maximum number of instances
216222
Type: Number
@@ -415,6 +421,8 @@ Outputs:
415421
Name: !Sub '${AWS::StackName}-InstanceRoleName'
416422

417423
Conditions:
424+
SpotPriceSet:
425+
!Not [ !Equals [ !Ref SpotPrice, 0 ] ]
418426

419427
CreateVpcResources:
420428
!Equals [ !Ref VpcId, "" ]
@@ -921,8 +929,9 @@ Resources:
921929
VPCZoneIdentifier: !If [ "CreateVpcResources", [ !Ref Subnet0, !Ref Subnet1 ], !Ref Subnets ]
922930
MixedInstancesPolicy:
923931
InstancesDistribution:
924-
OnDemandPercentageAboveBaseCapacity: !Ref OnDemandPercentage
932+
OnDemandPercentageAboveBaseCapacity: !If [ SpotPriceSet, 0, !Ref OnDemandPercentage ]
925933
SpotAllocationStrategy: capacity-optimized
934+
SpotMaxPrice: !If [SpotPriceSet, !Ref SpotPrice, !Ref "AWS::NoValue"]
926935
LaunchTemplate:
927936
LaunchTemplateSpecification:
928937
LaunchTemplateId: !Ref AgentLaunchTemplate

0 commit comments

Comments
 (0)