-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathstep_functions.aws.txt
3942 lines (3088 loc) · 218 KB
/
step_functions.aws.txt
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
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
┏━━━━━━━━━━━━━━━━━━━━┓
┃ STEP_FUNCTIONS ┃
┗━━━━━━━━━━━━━━━━━━━━┛
VERSION ==> #2025-03-14
SUMMARY ==> #Machine: version, alias, progressive deployment, encryption
#Express: pricing, scalable, duration, missing features, nesting
#Definition: lint, UI edit, graph
#Execution: async|sync, events, debug, redrive top|child, logging, tracing
#Input|output: transform, context, variables
#Error: error output, execution|task timeout, catch, retry, abort, fail
#States: type, start, next, choices, pass, wait, end
#Iterate: parallel, map items, inline|distributed, child machine|execution, tolerated fails, maxConcurrency, batch
#Iterate on S3: read (OBJECTs, JSON, CSV, INVENTORY), write
#Task: HTTP, AWS generic|optimized, nested, activity, job, async
#Query language: JSONata, JSONPath, intrisic functions
#API Gateway, EventBridge, local
┌─────────┐
│ API │
└─────────┘
NAME ==> #Sometimes abbreviated as SFN
SERVICE #'states'
SERVICE_DOMAIN #'[sync-]states.amazonaws.com'
#'sync' is when using StartSyncExecution()
FORMAT ==> #JSON REQ|RES with REQ.Action|Version
PAGINATION ==> #Uses REQ.maxResults (def 100, max 1000) + REQ|RES.nextToken
#ValidateStateMachineDefinition(): REQ.maxResults (def|max 100), no REQ|RES.nextToken, RES.truncated BOOL
#No pagination: ListTagsForResource()
#No pagination in SDK: ListStateMachineVersions|Aliases(), ValidateStateMachineDefinition()
EVENTUAL CONSISTENCY ==> #Create|update|delete take up to a few minutes
┌─────────┐
│ SDK │
└─────────┘
@aws-sdk/client-sfn #
┌─────────┐
│ CLI │
└─────────┘
aws stepfunctions ... #
┌────────────────┐
│ THROTTLING │
└────────────────┘
THROTTLING ==> #Per ACCOUNT + REGION
#All soft. Many are REGION-specific
#Following means RATE_LIMIT (burst BURST_LIMIT) (see token bucket algorithm doc)
# 1/s (burst 0): TestState()
# 1/s (burst 100):
# - Create*|Publish*|Update*|Delete*()
# - ValidateStateMachineDefinition()
# - ListStateMachineVersions|Aliases(), ListMapRuns(), ListTagsForResource()
# 1/s (burst 200): Describe*(), [Un]tagResource()
# 5/s (burst 100): ListStateMachines()
# 5/s (burst 200): ListExecutions()
# 10/s (burst 100): ListActivities()
# 15/s (burst 300): DescribeExecution()
# 20/s (burst 200): DescribeStateMachine()
# 20/s (burst 400): GetExecutionHistory()
# 200/s (burst 1000): StopExecution()
# 300/s (burst 1300): RedriveExecution()
# 500/s (burst 3000): GetActivityTask(), SendTask*()
# 1300/s (burst 300): StartExecution()
# None: StartSyncExecution()
┌────────────────────────┐
│ THROTTLING METRICS │
└────────────────────────┘
AWS/States/ProvisionedRefillRate #RATE_LIMIT
AWS/States/ProvisionedBucketSize #BURST_LIMIT
AWS/States/ConsumedCapacity #NUM of requests per second
AWS/States/ThrottledEvents #NUM of throttled requests
DVAR APIName #'ACTION'. With above METRICs
┌────────────────────────────┐
│ THROTTLING METRICS IAC │
└────────────────────────────┘
StateTransitionMetric.metric
('METRIC', CMETRIC_OPTS)
->CMETRIC #Must pass CMETRIC_OPTS.dimensionsMap { APIName: 'ACTION' }
StateTransitionMetric.metricMETRIC
(CMETRIC_OPTS)->CMETRIC #Same, except uses statistic 'Sum' for ThrottledEvents
┌─────────────┐
│ PRICING │
└─────────────┘
PRICING ==> #Not Express: 1$ per 4e4 STATE_EXECs
# - free: 4e3
#Express:
# - 1$ per 1e6 EXECs
# - 1$ per 1e6 EXECs with 1s duration and 64MB memory
# - proportional to duration
# - rounded up by 100ms per EXEC
# - 2x cheaper after 1000h, 4x after 5000h
# - proportional to memory
# - memory is sum of:
# - 50MB
# - DEFINITION
# - max(INPUT, OUTPUT)
# - for each child MACHINE run: max(INPUT, OUTPUT)
# - rounded up by 64MB per EXEC
# - "EXEC" is either top|child
# - i.e. include ITERs
#ENCRYPT: no KMS charge if type 'AWS_OWNED_KEY'
#Recommendations:
# - Express much cheaper
# - especially if STEPs are fast and use low memory
# - with Express, what matters more:
# - if <= 1s * 64MB: NUM of EXECs
# - else: duration and memory
# - Step Functions Express is roughly same price as Lambda
# - NUM of ITERs can multiply cost, for both Express and not
# - use BATCHs
EXEC.billingDetails #EXEC_BILLING
EXEC_BILLING
.billedDurationInMilliseconds #NUM of ms charged, after rounding up
EXEC_BILLING.billedMemoryUsedInMB #NUM of MB charged, after rounding up
┌─────────────────────┐
│ PRICING METRICS │
└─────────────────────┘
AWS/States/
ExpressExecutionBilledDuration #NUM of ms charged, after rounding up
AWS/States/ExpressExecutionMemory #NUM of MB charged, before rounding up
AWS/States/
ExpressExecutionBilledMemory #NUM of MB charged, after rounding up
DVAR StateMachineArn #'MACHINE_ARN'. With above METRICs
#MACHINE is also a TELEMETRY_ENTITY
┌──────────┐
│ AUTH │
└──────────┘
AWSStepFunctionsFullAccess #AWS managed POLICY. Allows all 'states:*' PACTIONs
AWSStepFunctionsConsoleFullAccess #Same but also allows:
# - iam:PassRole on ROLE 'service-role/StatesExecutionRole*'
# - iam:ListRoles
# - lambda:ListFunctions
#Meant for browsing Step Functions UI
AWSStepFunctionsReadOnlyAccess #Allows all read-only 'states:*' PACTIONs
┌─────────────┐
│ MACHINE │
└─────────────┘
MACHINE #Also called "workflow"
#Creation is idempotent (if same REQ)
#Update must specify at least either MACHINE.definition|roleArn (even if unchanged)
#Delete aborts ongoing EXECs and wait for them to fail
#Delete also delete VERSIONs|ALIASs
#Max 1e5 (soft up to 2.5e5) per ACCOUNT
MACHINE.stateMachineArn #In output: 'MACHINE_ARN'. 'arn:aws:states:REGION:ACCOUNT_ID:stateMachine:MACHINE'
#In input: 'QUALIFIED_MACHINE_ARN'
MACHINE.name #'MACHINE'
#Max 80 chars, [:alnum:]-_
MACHINE.creationDate #DATE_NUM
MACHINE.status #'ACTIVE' or 'DELETING'
CONTEXT.StateMachine.Id #'MACHINE_ARN'
CONTEXT.StateMachine.Name #'MACHINE'
┌────────────────┐
│ MACHINE UI │
└────────────────┘
WORKFLOW STUDIO ==> #UI to view|edit a MACHINE, as a graph
#Can create|deploy as a CloudFormation STACK
┌─────────────────────┐
│ MACHINE TOOLKIT │
└─────────────────────┘
WORKFLOW STUDIO ==> #Can be accessed from Explorer or from a .asl.json|y[a]ml
#A few features are missing when accessed this way
┌─────────────────┐
│ MACHINE API │
└─────────────────┘
CreateStateMachine() #Req: MACHINE + NEW_VERSION
# - no creationDate, label, status
# - no stateMachineArn
# - only one with tags
#Res: VERSION
# - no updateDate, revisionId
UpdateStateMachine() #Req: MACHINE + NEW_VERSION
# - no creationDate, label, status
# - no name, type
#Res: VERSION
# - no stateMachineArn, creationDate
ListStateMachines() #Req: empty
#Res: stateMachines MACHINE_ARR
# - only stateMachineArn, name, creationDate, type
DescribeStateMachine() #Req:
# - MACHINE: only stateMachineArn
# - MACHINE_GET
#Res:
# - MACHINE
# - VERSION: no stateMachineVersionArn, updateDate
DescribeStateMachineForExecution()#Req:
# - [ITEM_]EXEC: only executionArn
# - MACHINE_GET
#Res:
# - MACHINE: no creationDate, status, type
# - VERSION: no stateMachineVersionArn, description
# - ITEM_EXEC: only mapRunArn
DeleteStateMachine() #Req: MACHINE
# - only stateMachineArn
#Res: empty
┌─────────────────┐
│ MACHINE IAC │
└─────────────────┘
AWS::StepFunctions::StateMachine #RESPROPs: StateMachineName
#RESATTRs: Arn, Name
new StateMachine
(...CARGS, CMACHINE_OPTS)
->CMACHINE #
StateMachine.fromStateMachineArn
(...CARGS, 'MACHINE_ARN')
->ICMACHINE #
StateMachine.fromStateMachineName
(...CARGS, 'MACHINE')->ICMACHINE #
CMACHINE_OPTS.stateMachineName #MACHINE.name
ICMACHINE.activityName #'MACHINE'[_STR_TK]
ICMACHINE.activityArn #'MACHINE_ARN'[_STR_TK]
CMACHINE_OPTS.removalPolicy #Passed to CZRESOURCE.applyRemovalPolicy()
#Def: RemovalPolicy.DESTROY
JsonPath.stateMachineId $#'$$.StateMachine.Id'
JsonPath.stateMachineName $#'$$.StateMachine.Name'
┌─────────────────┐
│ MACHINE SAM │
└─────────────────┘
AWS::Serverless::StateMachine #Expands to MACHINE
#Optionally expands to:
# - ROLE
# - VERSION, ALIAS
# - API Gateway first-class integration: API, ROUTE, INTEGRATION, IRESP, RESP, ROLE
#Includes RESPROPs: Name
#Includes RESATTRs: Name
#Missing feature: ENCRYPT
┌──────────────────────┐
│ MACHINE COMPOSER │
└──────────────────────┘
MACHINE ENHANCED COMPONENT ==> #Includes MACHINE + POLICYs, as AWS::Serverless::StateMachine
#Can switch to Workflow studio
# - to edit MACHINE and its DEFINITION
# - a few features are missing when accessed this way
┌──────────────────┐
│ MACHINE LINT │
└──────────────────┘
DIAG_ERROR
STATE_MACHINE_NAME_EMPTY #MACHINE.name must be set
DIAG_ERROR
STATE_MACHINE_NAME_TOO_LONG #MACHINE.name must be <= 80 chars
DIAG_ERROR
STATE_MACHINE_NAME_INVALID #MACHINE.name must be valid
DIAG_ERROR
STATE_MACHINE_NAME_ALREADY_EXISTS#MACHINE with same name must not already exists
┌─────────────────────┐
│ MACHINE TOOLKIT │
└─────────────────────┘
MACHINE CRUD ==> #Can be done in "Explorer"
┌──────────────────┐
│ MACHINE ROLE │
└──────────────────┘
MACHINE|TEST_IN.roleArn #'ROLE_ARN'. Required
#Must be assumable by Principal.Service 'states.amazonaws.com'
EVENT_INFO.roleArn #'ROLE_ARN'
#With EVENT_TYPE ExecutionStarted
┌───────────────────────┐
│ MACHINE ROLE AUTH │
└───────────────────────┘
PACTION iam:PassRole #Must be allowed on current PRINCIPAL
┌─────────────────────┐
│ MACHINE ROLE UI │
└─────────────────────┘
ROLE 'service-role
/StatesExecutionRole*' #Created by Workflow studio for common MACHINE.roleArn use cases
┌──────────────────────┐
│ MACHINE ROLE IAC │
└──────────────────────┘
AWS::StepFunctions::StateMachine #RESPROPs: RoleArn
#MACHINE must DependsOn ROLE
CMACHINE[_OPTS].role #ICROLE. MACHINE.roleArn
#Def: new one assumable by Principal.Service 'states.amazonaws.com'
#CMACHINE (not ICMACHINE) is YGRANTABLE|KGRANTABLE using this ROLE
ICMACHINE.grant
(YGRANTABLE, 'PACTION',...)
->CGRANT #Allows PACTION on Resource MACHINE_ARN
ICMACHINE.grantRead(YGRANTABLE) #Allows PACTIONs:
->CGRANT # - states:ListStateMachines|ListExecutions on MACHINE
# - states:DescribeStateMachine|ListActivities on any MACHINE
# - states:Describe[StateMachineFor]Execution|GetExecutionHistory on any EXEC in this MACHINE
# - states:DescribeActivity on any ACTIVITY
CCUSTOM_TASK.taskPolicies #CSTATEMENT_ARR allowed to MACHINE.roleArn
┌──────────────────────┐
│ MACHINE ROLE SAM │
└──────────────────────┘
AWS::Serverless::StateMachine #Includes RESPROPs:
# - Role
# - def: automatically creates ROLE 'MACHINERole'
# - assumable by Principal.Service 'states.amazonaws.com'
# (for default RESPROP Role)
# - RolePath, PermissionsBoundary: same as AWS::IAM::Role
# - Policies SAM_POLICIES: like AWS::Serverless::Function (see its doc)
┌─────────────┐
│ VERSION │
└─────────────┘
VERSION #Public immutable version of a MACHINE
#Previous VERSIONs not automatically deleted
#PublishStateMachineVersion() is idempotent (if same REQ)
#Delete waits for ongoing EXECs to complete (and does not abort them)
#Cannot delete if there is an associated ALIAS
#Max 1e3 (soft) per MACHINE
VERSION.stateMachineVersionArn #'VERSION_ARN'. 'MACHINE_ARN:VERSION_NUM'
VERSION.stateMachineArn #'MACHINE_ARN'
VERSION_NUM #Automatically incremented by PublishStateMachineVersion(), starting at 1
#Similar to a git commit `hash`
#ListStateMachineVersions() sorts by it
VERSION.description
NEW_VERSION.versionDescription #STR. Max 256 chars
VERSION.creationDate #DATE_NUM
VERSION.updateDate #DATE_NUM
VERSION.revisionId #'REVISION_ID' (see aws_network doc)
#Is 'INITIAL' after create, before first update
#Each MACHINE update creates a new private one
#PublishStateMachineVersion() makes it public
NEW_VERSION.publish #BOOL (def: false). Calls PublishStateMachineVersion()
EVENT_INFO.stateMachineVersionArn #'VERSION_ARN'
#With EVENT_TYPE ExecutionStarted
┌──────────────────┐
│ VERSION AUTH │
└──────────────────┘
PACTION
states:PublishStateMachineVersion#Required for NEW_VERSION.publish true
┌─────────────────┐
│ VERSION API │
└─────────────────┘
PublishStateMachineVersion() #Req: VERSION
# - no stateMachineVersionArn, *Date
# - only one with description
#Res: VERSION
# - only stateMachineVersionArn, creationDate
ListStateMachineVersions() #Req: MACHINE
# - only stateMachineArn
#Res: stateMachineVersions VERSION_ARR
# - only stateMachineVersionArn, creationDate
DeleteStateMachineVersion() #Req: VERSION
# - only stateMachineVersionArn
#Res: empty
CreateStateMachine()
UpdateStateMachine()
DescribeStateMachine() #Return VERSION too (see above)
┌─────────────────┐
│ VERSION IAC │
└─────────────────┘
AWS::StepFunctions:: #RESPROPs:
StateMachineVersion # - StateMachineArn, Description
# - StateMachineRevisionId
# - to create a new VERSION everytime MACHINE changes, can set to !GetAtt MACHINE.StateMachineRevisionId
# - to point to a fixed VERSION, set a specific REVISION_ID instead
#RESATTRs: Arn
#With Cloud Control, cannot update (replace only)
AWS::StepFunctions::StateMachine #Includes RESATTR: StateMachineRevisionId
CMACHINE.stateMachineRevisionId #'REVISION_ID'_CSATTR
┌─────────────────┐
│ VERSION SAM │
└─────────────────┘
AWS::Serverless::StateMachine #Includes RESPROPs: AutoPublishAlias 'ALIAS' (def: none):
# - creates VERSION:
# - 'RESOURCE' is 'MACHINEVersion'
# - RESOURCE.DeletionPolicy|UpdateReplacePolicy 'Retain'
┌─────────────────────┐
│ VERSION METRICS │
└─────────────────────┘
AWS/States/VersionCount #NUM of VERSIONs
#DVAR ResourceArn 'VERSION_NUM'
DVAR Version #'VERSION_NUM'. With AWS/States/Execution*
┌───────────┐
│ ALIAS │
└───────────┘
ALIAS #'ALIAS' pointing to a VERSION
#Can change its target, similar to a git tag
#Create|update is idempotent (if same REQ)
#Delete does not delete any associated VERSION
#Max 100 (soft) per MACHINE
ALIAS.stateMachineAliasArn #'ALIAS_ARN'. 'MACHINE_ARN:ALIAS'
ALIAS.name #'ALIAS'
#Should avoid being a 'NUM', to prevent confusion with 'VERSION_NUM'
#Max 80 chars, [:alnum:]-_.
ALIAS.description #STR
#Max 256 chars
ALIAS.creationDate #DATE_NUM
ALIAS.updateDate #DATE_NUM
EVENT_INFO.stateMachineAliasArn #'ALIAS_ARN'
#With EVENT_TYPE ExecutionStarted
QUALIFIER #'VERSION_NUM|ALIAS'
QUALIFIED_MACHINE_ARN #'MACHINE_ARN[:QUALIFIER]' (def: latest VERSION)
┌────────────────┐
│ ALIAS AUTH │
└────────────────┘
COND_KEY #'VERSION_NUM|ALIAS'
states:StateMachineQualifier #Only with DeleteStateMachineVersion(), *Alias*(), DescribeStateMachine(),
#Start[Sync]Execution|ListExecutions()
┌───────────────┐
│ ALIAS API │
└───────────────┘
CreateStateMachineAlias() #Req: ALIAS
# - no stateMachineAliasArn, *Date
#Res: ALIAS
# - only stateMachineAliasArn, creationDate
UpdateStateMachineAlias() #Req: ALIAS
# - no name, *Date
#Res: ALIAS
# - only updateDate
ListStateMachineAliases() #Req: MACHINE
# - only stateMachineArn
#Res: stateMachineAliases ALIAS_ARR
# - only stateMachineAliasArn, creationDate
DescribeStateMachineAlias() #Req: ALIAS
# - only stateMachineAliasArn
#Res: ALIAS
DeleteStateMachineAlias() #Req: ALIAS
# - only stateMachineAliasArn
#Res: empty
┌───────────────┐
│ ALIAS IAC │
└───────────────┘
AWS::StepFunctions:: #RESPROPs: Name, Description, RoutingConfiguration
StateMachineAlias #RESATTRs: Arn
┌───────────────┐
│ ALIAS SAM │
└───────────────┘
AWS::Serverless::StateMachine #Includes RESPROPs:
# - AutoPublishAlias 'ALIAS' (def: none): creates ALIAS:
# - 'RESOURCE' is 'MACHINEAliasALIAS'
# (if AutoPublishAlias set)
=# - UseAliasAsEventTarget BOOL (def: false):
# - in first-class INTEGRATION created by Events.EVENT Type 'Api'
# - make it execute ALIAS (instead of latest VERSION)
# - by setting EXEC.stateMachineArn 'ALIAS_ARN' (instead of 'MACHINE_ARN')
┌───────────────────┐
│ ALIAS METRICS │
└───────────────────┘
AWS/States/AliasCount #NUM of ALIASs
#DVAR ResourceArn 'ALIAS_ARN'
DVAR Alias #'ALIAS_ARN'. With AWS/States/Execution*
┌────────────────┐
│ DEPLOYMENT │
└────────────────┘
ALIAS.routingConfiguration #ALIAS_ROUTING_ARR. Randomly execute one of several VERSIONs
#Min 1 item, max 2 items, i.e. meant for transitioning between 2 VERSIONs
ALIAS_ROUTING
.stateMachineVersionArn #'VERSION_ARN'
ALIAS_ROUTING.weight #NUM. 0 to 100
#Sum of all ALIAS_ROUTING.weight must be 100
ALIAS_DEPLOY #Alternative to ALIAS_ROUTING, which automates it
#When ALIAS created, progressively shift traffic from previous VERSION to new one
#Can only be set from IaC
ALIAS_DEPLOY
.StateMachineVersionArn #'VERSION_ARN'
ALIAS_DEPLOY.Type #How many increments to shift traffic:
# - 'ALL_AT_ONCE' ("blue/green"): 1
# - 'CANARY': 2
# - 'LINEAR' ("rolling"): multiple
ALIAS_DEPLOY.Interval #NUM (max 35h) of minutes between 2 increments
ALIAS_DEPLOY.Percentage #1-99 percentage of traffic increase with each increment (except last one)
ALIAS_DEPLOY.Alarms #CloudWatch 'ALARM'_ARR. Rollback if any has StateValue 'ALARM'
#Max 100 items
┌────────────────────┐
│ DEPLOYMENT IAC │
└────────────────────┘
AWS::StepFunctions::
StateMachineAlias #RESPROPs: DeploymentPreference ALIAS_DEPLOY
┌────────────────────┐
│ DEPLOYMENT SAM │
└────────────────────┘
AWS::Serverless::StateMachine #Includes RESPROPs:
# - AutoPublishAlias 'ALIAS' (def: none): sets ALIAS_DEPLOY with Type 'ALL_AT_ONCE'
# (if AutoPublishAlias set)
# - DeploymentPreference ALIAS_DEPLOY
┌─────────────┐
│ EXPRESS │
└─────────────┘
MACHINE.type #Either 'STANDARD' (def) or 'EXPRESS'
DMAP_CONF.ExecutionType #Same but for child MACHINE
RECOMMENDATIONS ==> #Pros:
# - cheaper when STEPs are fast and use low memory
# - more scalable when lots of EXECs|STATE_EXECs
#Cons:
# - fewer features
# - 5m timeout
# - must be idempotent
#I.e. best for EXECs that are short and|or used a lot
#Can use ITEM_EXECs or OPTIMIZED_NESTED_EXEC to:
# - keep parent as STANDARD
# - while making specific parts of it as EXPRESS
EXCLUSIVE FEATURES ==> #Different pricing (see above), usually cheaper
# - including EXEC_BILLING and AWS/States/Express* METRICs
#More scalable:
# - no max EXECs at once
# - no STATE_EXECs throttling
# - less throttling on StartExecution(): 6000 (burst 6000)
#StartSyncExecution()
SHORTER TASKS ==> #Def|max DMACHINE.TimeoutSeconds: only 5m
IDEMPOTENCY ==> #Logic must be idempotent because:
# - creating an EXEC is not idempotent
# - EXEC is sometimes run twice (at-least-once guarantee)
MISSING INFO|HISTORY ==> #Cannot retrieve EXEC, i.e.:
# - DescribeStateMachineForExecution(), ListExecutions()
# - DescribeExecution(): except for ITEM_EXEC
#No EVENTs
# - can use MACHINE_LOGGING instead (def level: 'ALL' instead)
SIMPLER TASKS ==> #No OPTIMIZED_SERVICE_TASK, ASYNC_TASK nor ACTIVITY_TASK
INLINE MAP ONLY ==> #No DMAP_CONF.Mode 'DISTRIBUTED'
NO ABORT|REDRIVE ==> #No StopExecution()
#No REDRIVE:
# - no REDRIVE for top-level EXECs: no RedriveExecution()
# - but can re-run failed ITERs by passing STATE_MAP_ARN to StartExecution()
# - however, already successful STATEs in a failed ITER are re-run
# - no ITEM_EXEC.redriveDate nor CONTEXT.Execution.RedriveCount
INTEGRATIONS ==> #No EventBridge EVENT 'Step Functions Execution Status Change'
EXEC_ARN #'arn:aws:states:REGION:ACCOUNT_ID:express:MACHINE:EXEC:EXPRESS_MID' instead
ITEM_EXEC_ARN #'arn:aws:states:REGION:ACCOUNT_ID:express:MACHINE/STATE_MAP_LABEL:EXEC:EXPRESS_MID' instead
┌────────────────┐
│ EXPRESS UI │
└────────────────┘
EVENT HISTORY ==> #Even though Express has no EVENTs, UI still shows a similar History page,
#providing MACHINE_LOGGING is enabled
┌─────────────────┐
│ EXPRESS IAC │
└─────────────────┘
AWS::StepFunctions::StateMachine #Includes RESPROPs: StateMachineType
CMACHINE[_OPTS].stateMachineType #MACHINE.type
CSTATE_MAP_OPTS.mapExecutionType #DMAP_CONF.ExecutionType
┌─────────────────┐
│ EXPRESS SAM │
└─────────────────┘
AWS::Serverless::StateMachine #Includes RESPROPs: Type
┌────────────────┐
│ DEFINITION │
└────────────────┘
MACHINE.definition #DEFINITION. 'DMACHINE_JSON'
#Format is ASL (Amazon States Language)
# - has a spec, i.e. abstract enough to have other implementors than Step Functions API
# - extension is .asl.json|y[a]ml
#Max 1MB
D* #Fields in 'DMACHINE_JSON'
DMACHINE.Version #Always '1.0' (def)
#Only for top-level MACHINE
DMACHINE.Comment #STR. Description
┌───────────────────┐
│ DEFINITION UI │
└───────────────────┘
GRAPH ==> #UI shows DEFINITION as a graph
#Can be exported as SVG|PNG
WORKFLOW STUDIO ==> #Shows DEFINITION as a graph
#Can be exported as SVG|PNG
STARTER TEMPLATE ==> #Scaffold common use cases
┌────────────────────┐
│ DEFINITION IAC │
└────────────────────┘
AWS::StepFunctions::StateMachine #Include RESPROP either:
# - DefinitionString 'DMACHINE_JSON'
# - DefinitionS3Location OBJ: Bucket 'BUCKET', Key 'OBJECT', Version 'VERSION_MID'
# - contains 'DMACHINE_JSON' or 'DMACHINE_YAML'
# - can use `aws cloudformation package` or `sam package`
# - Definition DMACHINE_OBJ
# - DefinitionSubstitutions.KEY STR:
# - replace any '${KEY}' by STR
# - inside contents of Definition*
# - can be used to pass !RFUNCs to Definition*, which does not allow it otherwise
CMACHINE_OPTS
.definitionSubstitutions #OBJ. RESPROP DefinitionSubstitutions
CMACHINE_OPTS.definitionBody #MACHINE.definition. Can be:
# - DefinitionBody.fromString('DMACHINE_JSON')
# - passed to RESPROP DefinitionString
# - DefinitionBody.fromFile('DEFINITION_PATH'[, HFOPTS])
# - uses a HFASSET
# - passed to RESPROP DefinitionS3Location
# - DefinitionBody.fromChainable(CTREE)
# - passed to RESPROP DefinitionString
#Can use CDK --hotswap (except with DefinitionBody.fromFile())
EXPORT ==> #In UI, can export MACHINE's DEFINITION as CloudFormation|SAM template, or to Infrastructure Composer
CMACHINE_OPTS.comment #DMACHINE.Comment
#Must use DefinitionBody.fromChainable()
┌────────────────────┐
│ DEFINITION SAM │
└────────────────────┘
AWS::Serverless::StateMachine #Includes RESPROPs:
# - DefinitionUri: S3_URL or OBJ
# - transformed to AWS::StepFunctions::StateMachine RESPROP DefinitionS3Location
# - can use `aws cloudformation package` or `sam package`
# - Definition DMACHINE_OBJ
# - transformed to AWS::StepFunctions::StateMachine RESPROP DefinitionString
# - DefinitionSubstitutions:
# - same as above
# - also allows having !RFUNC in Definition* by automatically:
# - replacing it by '${KEY}'
# - setting DefinitionSubstitutions.KEY !RFUNC
HOT RELOADING ==> #Supported by `sam sync` (see its doc)
# - contents is cached using DEFINITION (DefinitionS3Location|DefinitionUri's contents)
┌─────────────────────────┐
│ DEFINITION COMPOSER │
└─────────────────────────┘
MACHINE ENHANCED COMPONENT ==> #Can use external file for AWS::Serverless::StateMachine RESPROP DefinitionUri
┌─────────────────────┐
│ DEFINITION LINT │
└─────────────────────┘
DIAG_ERROR
INVALID_JSON_DESCRIPTION
statelint
asl-validator #DEFINITION must be valid JSON
DIAG_ERROR MISSING_DESCRIPTION
statelint
asl-validator #DEFINITION must not be empty
DIAG_ERROR
SCHEMA_VALIDATION_FAILED
statelint
asl-validator #DEFINITION must have no syntax error
cfn-lint E3601 #DEFINITION must have no syntax error
#Works with DefinitionSubstitutions
┌────────────────────────┐
│ DEFINITION TOOLKIT │
└────────────────────────┘
DOWNLOAD DEFINITION ==> #Can be done in "Explorer"
VISUALIZE DEFINITION ==> #Can visualize DEFINITION as a graph
DEFINITION TEMPLATES ==> #Can be used for scaffolding either starter template, or small DEFINITION parts ("snippets")
┌──────────────┐
│ VALIDATE │
└──────────────┘
VALIDATE_REQ #Validate DEFINITION for syntax errors
VALIDATE_REQ.definition|type #MACHINE.*
VALIDATE_REQ.diagnostic #Minimum DIAG.severity (def: 'ERROR', i.e. no WARNINGs)
VALIDATE_RES.result #'OK' or 'FAIL'. Whether any DIAG with severity 'ERROR'
VALIDATE_RES.diagnostics #DIAG_ARR. Paginated
#'CODE|MESSAGE' might change in the future, i.e. should not rely on current list
#The full list is documented in this doc
DIAG.code #'DIAG_CODE'
DIAG.message #'MESSAGE'
DIAG.severity #Either:
# - 'ERROR': prevents Create|UpdateStateMachine()
# - 'WARNING': does not prevent Create|UpdateStateMachine()
DIAG.location #STR. VAR's location, as JSON pointer, e.g. '/States/STATE/Output'
┌──────────────────┐
│ VALIDATE API │
└──────────────────┘
ValidateStateMachineDefinition() #Req: VALIDATE_REQ
#Res: VALIDATE_RES
┌───────────────┐
│ STATELINT │
└───────────────┘
statelint PATH ... #Validate DEFINITION files
#Version 0.8 (2024-11-21)
┌──────────────────┐
│ STATELINT UI │
└──────────────────┘
WORKFLOW STUDIO ==> #Lints, autocompletes and prettifies
┌───────────────────────┐
│ STATELINT TOOLKIT │
└───────────────────────┘
LINTING ==> #Lints, autocompletes and prettifies
┌───────────────────────┐
│ ASL VALIDATOR CLI │
└───────────────────────┘
asl-validator #Version 3.14.0
COMPARISON WITH STATELINT ==> #Pros:
# - covers more errors
# - better maintained
# - npm, not Ruby
# - can be used programmatically
#I.e. prefer asl-validator over statelint
COMPARISON WITH API ==> #Comparison with ValidateStateMachineDefinition()
#Pro: run locally, no API calls
#Con: their checks overlap, but they each some unique ones
#I.e. should use both
asl-validator #CLI. Validates DEFINITION for syntax errors
#Under-the-hood, uses both detailed JSON schemas and some custom logic
--json-definition #'DMACHINE_JSON'
--json-path #'PATH' to DEFINITION
--yaml-definition
--yaml-path #Same as YAML
--silent #BOOL (def: false). Only exit code, no stdout|stderr
┌───────────────────────┐
│ ASL VALIDATOR SDK │
└───────────────────────┘
VALIDATOR
(CMACHINE_OBJ[, VALIDATOR_OPTS])
->VALIDATOR_RES #Programmatic
VALIDATOR_RES.isValid #BOOL. Whether no VALIDATOR_ERROR_OBJs
VALIDATOR_RES.errorsText
(['DELIM'])->STR #'CODE: MESSAGE\n...', printed on stderr by CLI
VALIDATOR_RES.errors #VALIDATOR_ERROR_OBJ_ARR
VALIDATOR_ERROR_OBJ['Error code'] #'CODE'
VALIDATOR_ERROR_OBJ.Message #'MESSAGE'
VALIDATOR_ERROR_OBJ.schemaError
.instancePath|schemaPath #AJV_ERROR_OBJ.*
┌───────────────┐
│ EXECUTION │
└───────────────┘
EXEC #Execution of a MACHINE
#Create is idempotent (if same REQ and another is ongoing)
#Max 1e6 (soft) EXECs at once per ACCOUNT + REGION
# - else throw 'States.ExecutionLimitExceeded'
EXEC.executionArn #'EXEC_ARN'. 'arn:aws:states:REGION:ACCOUNT_ID:execution:MACHINE:EXEC'
EXEC.name #'EXEC' (def: random UUID)
#Max 80 chars, [:alnum:]-_
EXEC.startDate #DATE_NUM
EXEC.stopDate #DATE_NUM
EXEC.stateMachineArn #In input: 'QUALIFIED_MACHINE_ARN'
#In output: 'MACHINE_ARN'
EXEC.stateMachineVersionArn #'VERSION_ARN' (if specified)
EXEC.stateMachineAliasArn #'ALIAS_ARN' (if specified)
SYNC EXECUTION ==> #When using StartSyncExecution()
#Similar to StartExecution() + waiting for completion + returning DescribeExecution()
#EXEC.stateMachineArn must be 'MACHINE_ARN', not 'QUALIFIED_MACHINE_ARN'
EXEC.status #One of:
# - PENDING_REDRIVE
# - RUNNING
# - SUCCEEDED
# - FAILED
# - TIMED_OUT
# - ABORTED
CONTEXT.Execution.Id #'EXEC_ARN'
CONTEXT.Execution.Name #'EXEC'
CONTEXT.Execution.StartTime #EXEC.startDate, as 'DATE'
EVENT_TYPE ExecutionStarted
EVENT_TYPE ExecutionSucceeded
EVENT_TYPE ExecutionFailed
EVENT_TYPE ExecutionAborted #On EXEC start|end
┌──────────────────┐
│ EXECUTION UI │
└──────────────────┘
WORKFLOW STUDIO ==> #Can start an EXEC
#Not when accessed from Infrastructure Composer
┌───────────────────┐
│ EXECUTION API │
└───────────────────┘
StartExecution() #Req: EXEC
# - only stateMachineArn, name, input, traceHeader
#Res: EXEC
# - only executionArn, startDate
StartSyncExecution() #Req:
# - EXEC: only stateMachineArn, name, input, traceHeader
# - EXEC_GET
#Res: EXEC
# - no mapRunArn, redrive*, stateMachineVersionArn|stateMachineAliasArn
# - only one with billingDetails
ListExecutions() #Req: [ITEM_]EXEC
# - only either EXEC.stateMachineArn or ITEM_EXEC.mapRunArn
# - only status -> statusFilter
# - only one with redriveFilter
#Res: executions [ITEM_]EXEC_ARR
# - no cause, error, input*|output*, redriveStatus[Reason], traceHeader
# - only one with itemCount
DescribeExecution() #Req:
# - [ITEM_]EXEC: only executionArn
# - EXEC_GET
#Res: [ITEM_]EXEC
StopExecution() #Req: [ITEM_]EXEC
# - only executionArn, cause, error
#Res: [ITEM_]EXEC
# - only stopDate
┌───────────────────┐
│ EXECUTION IAC │
└───────────────────┘
JsonPath.executionId $#'$$.Execution.Id'
JsonPath.executionName $#'$$.Execution.Name'
JsonPath.executionStartTime $#'$$.Execution.StartTime'
ICMACHINE.grantExecution
(YGRANTABLE, 'PACTION',...) #Allows PACTION on any EXEC in this MACHINE
->CGRANT #I.e. Resource 'arn:aws:states:REGION:ACCOUNT_ID:execution:MACHINE:*'
ICMACHINE
.grantStart[Sync]Execution
(YGRANTABLE)->CGRANT #Allows PACTION 'states:Start[Sync]Execution' to MACHINE
ICMACHINE.grantRead(YGRANTABLE)
->CGRANT #See above
┌───────────────────────┐
│ EXECUTION SAM CLI │
└───────────────────────┘
sam remote invoke ['MACHINE'] #Calls StartExecution()
#Def: guessed if only one possible in current STACK
--event|-e #REQ.Input (def: '{}')
--event-file #Same but as 'FILE' or '-' (stdin)
--parameter #'PARAM=VAL ...'. REQ.*
#Def EXEC.name: 'sam_remote_invoke_DATE'
#Always sets EXEC.stateMachineArn
--output #Either:
# - 'text' (def): prints OUTPUT on stdout, ERROR_OUTPUT on stderr
# - 'json': prints both on stdout
┌───────────────────┐
│ EXECUTION SAM │
└───────────────────┘
StepFunctionsExecutionPolicy_v2 #SAM POLICY_TEMPLATE (see its doc) that allows:
# - PACTION states:Start[Sync]Execution
# - on 'MACHINE'
# - using POLICY_TEMPLATE_PARAMS.StateMachineName
AWS::Serverless::Connector #Can be used with:
# - Source: Lambda FUNCTION (RESOURCE_REF.RoleName)
# - Destination: MACHINE (RESOURCE_REF.Arn + RESOURCE_REF.Name)
# - Permissions 'Read' and|or 'Write'
#Transformed to a MPOLICY on 'ROLE':
# - allowing on MACHINE (from Arn):
# - Read: states:ListExecutions|DescribeStateMachine
# - Write: states:Start[Sync]Execution
# - allowing on EXECUTION/* (from Name):
# - Read: states:DescribeExecution|DescribeStateMachineForExecution|GetExecutionHistory
# - Write: states:StopExecution
┌───────────────────────┐
│ EXECUTION METRICS │
└───────────────────────┘
AWS/States/ExecutionTime #EXEC duration (in ms)
#cdk-monitoring-constructs: