This repository has been archived by the owner on Dec 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
sam.yml
651 lines (627 loc) · 23.4 KB
/
sam.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
---
AWSTemplateFormatVersion: 2010-09-09
Description: Step Functions for Spoptimize
Transform: AWS::Serverless-2016-10-31
Parameters:
StackBasename:
Description: Base name of Spoptimize resources
Type: String
Default: spoptimize
RolePath:
Description: Path of IAM resources
Type: String
Default: /
SnsTopicNameOverride:
Description: Name of existing SNS topic that publishes autoscaling launch notifications
Type: String
Default: default
DebugLambdas:
Description: Enable debug logging of lambda functions
Type: String
Default: "false"
AllowedValues: ["false", "true"]
MaximumIterationCount:
Description: Maximum number of iterations
Type: Number
Default: 48
AlarmTopicName:
Description: Name of SNS topic for CloudWatch Alarms
Type: String
Default: ""
IamTemplateUrl:
Description: Base URL of IAM template in S3 (replace token with URL to deploy all resources)
Type: String
Default: '' # URL_TOKEN
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
-
Label:
default: Basic Configuration
Parameters:
- StackBasename
- AlarmTopicName
- DebugLambdas
-
Label:
default: Advanced Configuration
Parameters:
- SnsTopicNameOverride
- RolePath
- MaximumIterationCount
- IamTemplateUrl
ParameterLabels:
StackBaseName:
default: Name prefix for spoptimize resources
AlarmTopicName:
default: Topic Name for Alarms
SnsTopicNameOverride:
default: Override for Launch Notification Topic
DebugLambdas:
default: Debug Lambdas?
RolePath:
default: Path override for IAM resources
MaximumIterationCount:
default: Max iterations after failed spot requests
IamTemplateUrl:
default: Humans probably shouldn't change this
Conditions:
NoAlarmNotifications: !Equals [!Ref AlarmTopicName, '']
DefaultSnsTopic: !Equals [!Ref SnsTopicNameOverride, 'default']
CreateIamStack: !Not [!Equals [!Ref IamTemplateUrl, '']]
CreateLaunchTopic: !And [
!Equals [!Ref SnsTopicNameOverride, 'default'],
!Not [!Equals [!Ref IamTemplateUrl, '']]
]
Globals:
Function:
Runtime: python2.7
Timeout: 30
Handler: handler.handler
MemorySize: 1024
Environment:
Variables:
SPOPTIMIZE_DEBUG: !Ref DebugLambdas
SPOPTIMIZE_LOCK_TABLE: !Ref LockTable
SPOPTIMIZE_SFN_ARN: !Ref SpotRequestor
Resources:
LaunchTopic:
Type: AWS::SNS::Topic
Condition: CreateLaunchTopic
Properties:
DisplayName: !Sub "autoscaling launch notifications - ${AWS::StackName}"
TopicName: !Sub "${StackBasename}-init"
Iam:
Type: AWS::CloudFormation::Stack
Condition: CreateIamStack
Properties:
TemplateURL: !Ref IamTemplateUrl
Parameters:
StackBasename: !Ref StackBasename
RolePath: !Ref RolePath
LockTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: !Sub "${StackBasename}-autoscaling-group-locks"
AttributeDefinitions:
- AttributeName: group_name
AttributeType: S
KeySchema:
- AttributeName: group_name
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
TimeToLiveSpecification:
AttributeName: ttl
Enabled: true
StartStateMachineFn:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub "${StackBasename}-start-state-machine"
Description: Processes autoscaling launch notifications via SNS and starts Spoptimize Step Functions
Role: !If [
CreateIamStack,
!GetAtt [Iam, Outputs.LambdaRoleArn],
!Sub "arn:aws:iam::${AWS::AccountId}:role${RolePath}${StackBasename}-iam-global-lambda-role"
]
CodeUri: ./target/lambda-pkg.zip
Environment:
Variables:
SPOPTIMIZE_ACTION: 'start-state-machine'
Events:
AsgLaunchNotifications:
Type: SNS
Properties:
Topic: !If [
DefaultSnsTopic,
!Sub "arn:aws:sns:${AWS::Region}:${AWS::AccountId}:${StackBasename}-init",
!Sub "arn:aws:sns:${AWS::Region}:${AWS::AccountId}:${SnsTopicNameOverride}"
]
SpotWarningFn:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub "${StackBasename}-spot-warning"
Description: Processes EC2 spot instance warnings and terminates via autoscaling API
Role: !If [
CreateIamStack,
!GetAtt [Iam, Outputs.LambdaRoleArn],
!Sub "arn:aws:iam::${AWS::AccountId}:role${RolePath}${StackBasename}-iam-global-lambda-role"
]
CodeUri: ./target/lambda-pkg.zip
Handler: handler.spot_warning_handler
Events:
SpotWarningForSpoptimize:
Type: CloudWatchEvent
Properties:
Pattern:
source: ["aws.ec2"]
detail-type: ["EC2 Spot Instance Interruption Warning"]
TestNewAsgInstanceFn:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub "${StackBasename}-ondemand-instance-healthy"
Description: Checks health and status of launched autoscaling instance
Role: !If [
CreateIamStack,
!GetAtt [Iam, Outputs.LambdaRoleArn],
!Sub "arn:aws:iam::${AWS::AccountId}:role${RolePath}${StackBasename}-iam-global-lambda-role"
]
CodeUri: ./target/lambda-pkg.zip
Environment:
Variables:
SPOPTIMIZE_ACTION: 'ondemand-instance-healthy'
IncrementCountFn:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub "${StackBasename}-increment-count"
Description: Increment iteration counter
Role: !If [
CreateIamStack,
!GetAtt [Iam, Outputs.LambdaRoleArn],
!Sub "arn:aws:iam::${AWS::AccountId}:role${RolePath}${StackBasename}-iam-global-lambda-role"
]
CodeUri: ./target/lambda-pkg.zip
Environment:
Variables:
SPOPTIMIZE_ACTION: 'increment-count'
RequestSpotInstanceFn:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub "${StackBasename}-request-spot"
Description: Requests a spot instance to replace launched autoscaling instance
Role: !If [
CreateIamStack,
!GetAtt [Iam, Outputs.LambdaRoleArn],
!Sub "arn:aws:iam::${AWS::AccountId}:role${RolePath}${StackBasename}-iam-global-lambda-role"
]
CodeUri: ./target/lambda-pkg.zip
Environment:
Variables:
SPOPTIMIZE_ACTION: 'request-spot'
CheckSpotRequestFn:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub "${StackBasename}-check-spot"
Description: Checks the status of spot instance request
Role: !If [
CreateIamStack,
!GetAtt [Iam, Outputs.LambdaRoleArn],
!Sub "arn:aws:iam::${AWS::AccountId}:role${RolePath}${StackBasename}-iam-global-lambda-role"
]
CodeUri: ./target/lambda-pkg.zip
Environment:
Variables:
SPOPTIMIZE_ACTION: 'check-spot'
AutoScalingGroupDisappearedFn:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub "${StackBasename}-term-spot-instance"
Description: Terminates spot instance (if online) after autoscaling group disappears
Role: !If [
CreateIamStack,
!GetAtt [Iam, Outputs.LambdaRoleArn],
!Sub "arn:aws:iam::${AWS::AccountId}:role${RolePath}${StackBasename}-iam-global-lambda-role"
]
CodeUri: ./target/lambda-pkg.zip
Environment:
Variables:
SPOPTIMIZE_ACTION: 'term-spot-instance'
AcquireAutoScalingGroupLock:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub "${StackBasename}-acquire-lock"
Description: Acquires lock for autoscaling group
Role: !If [
CreateIamStack,
!GetAtt [Iam, Outputs.LambdaRoleArn],
!Sub "arn:aws:iam::${AWS::AccountId}:role${RolePath}${StackBasename}-iam-global-lambda-role"
]
CodeUri: ./target/lambda-pkg.zip
Environment:
Variables:
SPOPTIMIZE_ACTION: 'acquire-lock'
ReleaseAutoScalingGroupLock:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub "${StackBasename}-release-lock"
Description: Releases lock for autoscaling group
Role: !If [
CreateIamStack,
!GetAtt [Iam, Outputs.LambdaRoleArn],
!Sub "arn:aws:iam::${AWS::AccountId}:role${RolePath}${StackBasename}-iam-global-lambda-role"
]
CodeUri: ./target/lambda-pkg.zip
Environment:
Variables:
SPOPTIMIZE_ACTION: 'release-lock'
AttachSpot:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub "${StackBasename}-attach-spot"
Description: Attaches spot instance to autoscaling group
Role: !If [
CreateIamStack,
!GetAtt [Iam, Outputs.LambdaRoleArn],
!Sub "arn:aws:iam::${AWS::AccountId}:role${RolePath}${StackBasename}-iam-global-lambda-role"
]
CodeUri: ./target/lambda-pkg.zip
Environment:
Variables:
SPOPTIMIZE_ACTION: 'attach-spot'
TestAttachedInstance:
Type: AWS::Serverless::Function
Properties:
FunctionName: !Sub "${StackBasename}-spot-instance-healthy"
Description: Checks health and status of attached spot instance
Role: !If [
CreateIamStack,
!GetAtt [Iam, Outputs.LambdaRoleArn],
!Sub "arn:aws:iam::${AWS::AccountId}:role${RolePath}${StackBasename}-iam-global-lambda-role"
]
CodeUri: ./target/lambda-pkg.zip
Environment:
Variables:
SPOPTIMIZE_ACTION: 'spot-instance-healthy'
SpotRequestor:
Type: AWS::StepFunctions::StateMachine
Properties:
StateMachineName: !Sub "${StackBasename}-spot-requestor"
RoleArn: !If [
CreateIamStack,
!GetAtt [Iam, Outputs.StateMachineRoleArn],
!Sub "arn:aws:iam::${AWS::AccountId}:role${RolePath}${StackBasename}-iam-global-state-machine"
]
DefinitionString:
Fn::Sub: |-
{
"Comment": "Spoptimize State Machine",
"StartAt": "Wait for New ASG Instance",
"States": {
"Wait for New ASG Instance": {
"Type": "Wait",
"SecondsPath": "$.init_sleep_interval",
"Next": "Test New ASG Instance"
},
"Test New ASG Instance": {
"Type": "Task",
"Resource": "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${StackBasename}-ondemand-instance-healthy",
"Next": "OD Instance Healthy?",
"ResultPath": "$.ondemand_instance_status",
"Retry": [{
"ErrorEquals": [ "InstancePending" ],
"IntervalSeconds": 30,
"MaxAttempts": 30,
"BackoffRate": 1
},{
"ErrorEquals": [ "States.ALL" ],
"IntervalSeconds": 5,
"MaxAttempts": 5,
"BackoffRate": 2.5
}]
},
"OD Instance Healthy?": {
"Type": "Choice",
"Choices": [{
"Variable": "$.ondemand_instance_status",
"StringEquals": "Healthy",
"Next": "Request Spot Instance"
},{
"Variable": "$.ondemand_instance_status",
"StringEquals": "Terminated",
"Next": "Instance Protected/Detached/Terminated or ASG Disappeared"
},{
"Variable": "$.ondemand_instance_status",
"StringEquals": "Protected",
"Next": "Instance Protected/Detached/Terminated or ASG Disappeared"
},{
"Variable": "$.ondemand_instance_status",
"StringEquals": "AutoScaling Group Disappeared",
"Next": "Instance Protected/Detached/Terminated or ASG Disappeared"
}],
"Default": "Unrecoverable OD Instance Failure"
},
"Unrecoverable OD Instance Failure": {
"Type": "Fail"
},
"Instance Protected/Detached/Terminated or ASG Disappeared": {
"Type": "Succeed"
},
"Request Spot Instance": {
"Type": "Task",
"Resource": "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${StackBasename}-request-spot",
"ResultPath": "$.spot_request",
"Next": "Wait For Spot Request",
"Retry": [{
"ErrorEquals": [ "States.ALL" ],
"IntervalSeconds": 5,
"MaxAttempts": 5,
"BackoffRate": 2.5
}]
},
"Wait For Spot Request": {
"Type": "Wait",
"SecondsPath": "$.spot_req_sleep_interval",
"Next": "Check Spot Request"
},
"Check Spot Request": {
"Type": "Task",
"Resource": "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${StackBasename}-check-spot",
"Next": "Spot Request Status?",
"ResultPath": "$.spot_request_result",
"Retry": [{
"ErrorEquals": [ "States.ALL" ],
"IntervalSeconds": 5,
"MaxAttempts": 5,
"BackoffRate": 2.5
}]
},
"Spot Request Status?": {
"Type": "Choice",
"Choices": [{
"Variable": "$.spot_request_result",
"StringEquals": "Pending",
"Next": "Wait For Spot Request"
},{
"Variable": "$.spot_request_result",
"StringEquals": "Failure",
"Next": "Increment Failure Count"
}],
"Default": "Acquire AutoScaling Group Lock"
},
"Increment Failure Count": {
"Type": "Task",
"Resource": "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${StackBasename}-increment-count",
"Next": "Check Iteration Count?",
"ResultPath": "$.iteration_count",
"Retry": [{
"ErrorEquals": [ "States.ALL" ],
"IntervalSeconds": 1,
"MaxAttempts": 5
}]
},
"Check Iteration Count?": {
"Type": "Choice",
"Choices": [{
"Variable": "$.iteration_count",
"NumericLessThanEquals": ${MaximumIterationCount},
"Next": "Sleep after Failed Spot Request"
}],
"Default": "Execution Exhaustion"
},
"Execution Exhaustion": {
"Type": "Fail"
},
"Sleep after Failed Spot Request": {
"Type": "Wait",
"SecondsPath": "$.spot_failure_sleep_interval",
"Next": "Test New ASG Instance"
},
"Release Lock Before Spot Term": {
"Type": "Task",
"Resource": "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${StackBasename}-release-lock",
"ResultPath": "$.asg_lock",
"Next": "Terminate Spot",
"Retry": [{
"ErrorEquals": [ "States.ALL" ],
"IntervalSeconds": 5,
"MaxAttempts": 5,
"BackoffRate": 2.5
}]
},
"Terminate Spot": {
"Type": "Task",
"Resource": "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${StackBasename}-term-spot-instance",
"End": true,
"Retry": [{
"ErrorEquals": [ "States.ALL" ],
"IntervalSeconds": 5,
"MaxAttempts": 5,
"BackoffRate": 2.5
}]
},
"Acquire AutoScaling Group Lock": {
"Type": "Task",
"Resource": "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${StackBasename}-acquire-lock",
"ResultPath": "$.asg_lock",
"Next": "Attach Spot Instance",
"Retry": [{
"ErrorEquals": [ "GroupLocked" ],
"IntervalSeconds": 5,
"MaxAttempts": 20,
"BackoffRate": 1.5
},{
"ErrorEquals": [ "States.ALL" ],
"IntervalSeconds": 5,
"MaxAttempts": 5,
"BackoffRate": 2.5
}]
},
"Attach Spot Instance": {
"Type": "Task",
"Resource": "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${StackBasename}-attach-spot",
"ResultPath": "$.spot_attach_result",
"Next": "Check Attachment?",
"Retry": [{
"ErrorEquals": [ "States.ALL" ],
"IntervalSeconds": 5,
"MaxAttempts": 5,
"BackoffRate": 2.5
}]
},
"Check Attachment?": {
"Type": "Choice",
"Choices": [{
"Variable": "$.spot_attach_result",
"StringEquals": "AutoScaling Group Disappeared",
"Next": "Release Lock Before Spot Term"
},{
"Variable": "$.spot_attach_result",
"StringEquals": "OD Instance Disappeared Or Protected",
"Next": "Release Lock Before Spot Term"
},{
"Variable": "$.spot_attach_result",
"StringEquals": "AutoScaling group not sized correctly",
"Next": "Release Lock Before Spot Term"
},{
"Variable": "$.spot_attach_result",
"StringEquals": "Spot Instance Disappeared",
"Next": "Release Lock Before Increment"
},{
"Variable": "$.spot_attach_result",
"StringEquals": "Instance missing",
"Next": "Release Lock Before Increment"
},{
"Variable": "$.spot_attach_result",
"StringEquals": "Invalid instance",
"Next": "Release Lock Before Increment"
}],
"Default": "Wait for Attachment"
},
"Release Lock Before Increment": {
"Type": "Task",
"Resource": "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${StackBasename}-release-lock",
"ResultPath": "$.asg_lock",
"Next": "Increment Failure Count",
"Retry": [{
"ErrorEquals": [ "States.ALL" ],
"IntervalSeconds": 5,
"MaxAttempts": 5,
"BackoffRate": 2.5
}]
},
"Wait for Attachment": {
"Type": "Wait",
"SecondsPath": "$.spot_attach_sleep_interval",
"Next": "Test Attached Instance"
},
"Test Attached Instance": {
"Type": "Task",
"Resource": "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${StackBasename}-spot-instance-healthy",
"Next": "Spot Instance Healthy?",
"ResultPath": "$.spot_instance_status",
"Retry": [{
"ErrorEquals": [ "InstancePending" ],
"IntervalSeconds": 30,
"MaxAttempts": 30,
"BackoffRate": 1
},{
"ErrorEquals": [ "States.ALL" ],
"IntervalSeconds": 5,
"MaxAttempts": 5,
"BackoffRate": 2.5
}]
},
"Spot Instance Healthy?": {
"Type": "Choice",
"Choices": [{
"Variable": "$.spot_instance_status",
"StringEquals": "Healthy",
"Next": "Release Lock after Success"
},{
"Variable": "$.spot_instance_status",
"StringEquals": "AutoScaling Group Disappeared",
"Next": "Release Lock Before Spot Term"
}],
"Default": "Release Lock After Spot Failure"
},
"Release Lock After Spot Failure": {
"Type": "Task",
"Resource": "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${StackBasename}-release-lock",
"ResultPath": "$.asg_lock",
"Next": "Unrecoverable Spot Instance Failure",
"Retry": [{
"ErrorEquals": [ "States.ALL" ],
"IntervalSeconds": 5,
"MaxAttempts": 5,
"BackoffRate": 2.5
}]
},
"Unrecoverable Spot Instance Failure": {
"Type": "Fail"
},
"Release Lock after Success": {
"Type": "Task",
"Resource": "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${StackBasename}-release-lock",
"ResultPath": "$.asg_lock",
"End": true,
"Retry": [{
"ErrorEquals": [ "States.ALL" ],
"IntervalSeconds": 5,
"MaxAttempts": 5,
"BackoffRate": 2.5
}]
}
}
}
SpotRequestorFailedAlrm:
Type: AWS::CloudWatch::Alarm
Properties:
AlarmName: !Sub "${AWS::StackName}-failed-executions"
AlarmDescription: "Failed executions of Spoptimize spot-requestor step functions"
Namespace: AWS/States
MetricName: ExecutionsFailed
Dimensions:
- Name: StateMachineArn
Value: !Ref SpotRequestor
Period: 300
EvaluationPeriods: 1
Statistic: Sum
ComparisonOperator: GreaterThanThreshold
Threshold: 0
TreatMissingData: notBreaching
ActionsEnabled: !If [NoAlarmNotifications, false, true]
AlarmActions:
Fn::If:
- NoAlarmNotifications
- !Ref AWS::NoValue
- [!Sub "arn:aws:sns:${AWS::Region}:${AWS::AccountId}:${AlarmTopicName}"]
SpotRequestorTimedOutAlrm:
Type: AWS::CloudWatch::Alarm
Properties:
AlarmName: !Sub "${AWS::StackName}-timed-out-executions"
AlarmDescription: "Timed Out executions of Spoptimize spot-requestor step functions"
Namespace: AWS/States
MetricName: ExecutionsTimedOut
Dimensions:
- Name: StateMachineArn
Value: !Ref SpotRequestor
Period: 300
EvaluationPeriods: 1
Statistic: Sum
ComparisonOperator: GreaterThanThreshold
Threshold: 0
TreatMissingData: notBreaching
ActionsEnabled: !If [NoAlarmNotifications, false, true]
AlarmActions:
Fn::If:
- NoAlarmNotifications
- !Ref AWS::NoValue
- [!Sub "arn:aws:sns:${AWS::Region}:${AWS::AccountId}:${AlarmTopicName}"]
Outputs:
SpotRequestorArn:
Description: Arn of Spot Requestor State Machine
Value: !Ref SpotRequestor
SpotRequestorName:
Description: Name of Spot Requestor State Machine
Value: !GetAtt SpotRequestor.Name