Skip to content

Commit 0594a72

Browse files
committed
[bugfix/18] Poor treating of Map/Parallel states marked as End: true
1 parent 41f76d9 commit 0594a72

File tree

8 files changed

+334
-48
lines changed

8 files changed

+334
-48
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"Comment": "A Hello World example of the Amazon States Language using a Pass state",
3+
"StartAt": "Start",
4+
"States": {
5+
"Start": {
6+
"Type": "Pass",
7+
"Next": "Succeed"
8+
},
9+
"Succeed": {
10+
"Type": "Succeed"
11+
}
12+
}
13+
}

examples/asl/json/2_1_choice.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"Comment": "A Hello World example of the Amazon States Language using a Pass state",
3+
"StartAt": "ChoiceStateX",
4+
"States": {
5+
"ChoiceStateX": {
6+
"Type": "Choice",
7+
"Choices": [
8+
{
9+
"Not": {
10+
"Variable": "$.type",
11+
"StringEquals": "Private"
12+
},
13+
"Next": "Public"
14+
},
15+
{
16+
"And": [
17+
{
18+
"Variable": "$.value",
19+
"NumericGreaterThanEquals": 20
20+
},
21+
{
22+
"Variable": "$.value",
23+
"NumericLessThan": 30
24+
}
25+
],
26+
"Next": "ValueInTwenties"
27+
},
28+
{
29+
"Variable": "$.value",
30+
"NumericEquals": 0,
31+
"Next": "ValueIsZero"
32+
}
33+
]
34+
},
35+
36+
"Public": {
37+
"Type": "Task",
38+
"Resource": "arn:aws:lambda:us-east-1:123456789012:function:Foo",
39+
"End": true
40+
},
41+
42+
"ValueIsZero": {
43+
"Type": "Task",
44+
"Resource": "arn:aws:lambda:us-east-1:123456789012:function:Zero",
45+
"End": true
46+
},
47+
48+
"ValueInTwenties": {
49+
"Type": "Task",
50+
"Resource": "arn:aws:lambda:us-east-1:123456789012:function:Bar",
51+
"End": true
52+
}
53+
}
54+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"Comment": "Parallel Example.",
3+
"StartAt": "LookupCustomerInfo",
4+
"States": {
5+
"LookupCustomerInfo": {
6+
"Type": "Parallel",
7+
"End": true,
8+
"Branches": [
9+
{
10+
"StartAt": "LookupAddress",
11+
"States": {
12+
"LookupAddress": {
13+
"Type": "Task",
14+
"Resource": "arn:aws:lambda:us-east-1:123456789012:function:AddressFinder",
15+
"End": true
16+
}
17+
}
18+
},
19+
{
20+
"StartAt": "LookupPhone",
21+
"States": {
22+
"LookupPhone": {
23+
"Type": "Task",
24+
"Resource": "arn:aws:lambda:us-east-1:123456789012:function:PhoneFinder",
25+
"Next": "Map"
26+
},
27+
"Map": {
28+
"Type": "Map",
29+
"End": true,
30+
"ItemsPath": "$.Ids",
31+
"Iterator": {
32+
"StartAt": "SyncItem",
33+
"States": {
34+
"SyncItem": {
35+
"Retry": [
36+
{
37+
"ErrorEquals": ["States.ALL"],
38+
"IntervalSeconds": 1,
39+
"BackoffRate": 2,
40+
"MaxAttempts": 3
41+
}
42+
],
43+
"Catch": [
44+
{
45+
"ErrorEquals": ["States.ALL"],
46+
"Next": "LogError"
47+
}
48+
],
49+
"End": true,
50+
"OutputPath": "$.Payload",
51+
"Parameters": {
52+
"FunctionName.$": "$.FunctionName",
53+
"Payload": {
54+
"ItemId.$": "$.ItemId"
55+
}
56+
},
57+
"Resource": "arn:aws:states:::lambda:invoke",
58+
"Type": "Task"
59+
},
60+
"LogError": {
61+
"Type": "Pass",
62+
"End": true
63+
}
64+
}
65+
},
66+
"MaxConcurrency": 20,
67+
"Parameters": {
68+
"FunctionName.$": "$.FunctionName",
69+
"ItemId.$": "$$.Map.Item.Value"
70+
}
71+
}
72+
}
73+
}
74+
]
75+
}
76+
}
77+
}

examples/asl/json/6_1_end_map.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"StartAt": "Map",
3+
"States": {
4+
"Map": {
5+
"Type": "Map",
6+
"End": true,
7+
"ItemsPath": "$.Ids",
8+
"Iterator": {
9+
"StartAt": "SyncItem",
10+
"States": {
11+
"SyncItem": {
12+
"Retry": [
13+
{
14+
"ErrorEquals": ["States.ALL"],
15+
"IntervalSeconds": 1,
16+
"BackoffRate": 2,
17+
"MaxAttempts": 3
18+
}
19+
],
20+
"Catch": [
21+
{
22+
"ErrorEquals": ["States.ALL"],
23+
"Next": "LogError"
24+
}
25+
],
26+
"End": true,
27+
"OutputPath": "$.Payload",
28+
"Parameters": {
29+
"FunctionName.$": "$.FunctionName",
30+
"Payload": {
31+
"ItemId.$": "$.ItemId"
32+
}
33+
},
34+
"Resource": "arn:aws:states:::lambda:invoke",
35+
"Type": "Task"
36+
},
37+
"LogError": {
38+
"Type": "Pass",
39+
"End": true
40+
}
41+
}
42+
},
43+
"MaxConcurrency": 20,
44+
"Parameters": {
45+
"FunctionName.$": "$.FunctionName",
46+
"ItemId.$": "$$.Map.Item.Value"
47+
}
48+
}
49+
}
50+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"StartAt": "Map",
3+
"States": {
4+
"Map": {
5+
"Type": "Map",
6+
"End": true,
7+
"ItemsPath": "$.Ids",
8+
"Iterator": {
9+
"StartAt": "SyncItem",
10+
"States": {
11+
"SyncItem": {
12+
"Retry": [
13+
{
14+
"ErrorEquals": ["States.ALL"],
15+
"IntervalSeconds": 1,
16+
"BackoffRate": 2,
17+
"MaxAttempts": 3
18+
}
19+
],
20+
"Catch": [
21+
{
22+
"ErrorEquals": ["States.ALL"],
23+
"Next": "LogError"
24+
}
25+
],
26+
"End": true,
27+
"OutputPath": "$.Payload",
28+
"Parameters": {
29+
"FunctionName.$": "$.FunctionName",
30+
"Payload": {
31+
"ItemId.$": "$.ItemId"
32+
}
33+
},
34+
"Resource": "arn:aws:states:::lambda:invoke",
35+
"Type": "Task"
36+
},
37+
"LogError": {
38+
"Type": "Pass",
39+
"Next": "LookupCustomerInfo"
40+
},
41+
"LookupCustomerInfo": {
42+
"Type": "Parallel",
43+
"End": true,
44+
"Branches": [
45+
{
46+
"StartAt": "LookupAddress",
47+
"States": {
48+
"LookupAddress": {
49+
"Type": "Task",
50+
"Resource": "arn:aws:lambda:us-east-1:123456789012:function:AddressFinder",
51+
"End": true
52+
}
53+
}
54+
},
55+
{
56+
"StartAt": "LookupPhone",
57+
"States": {
58+
"LookupPhone": {
59+
"Type": "Task",
60+
"Resource": "arn:aws:lambda:us-east-1:123456789012:function:PhoneFinder",
61+
"End": true
62+
}
63+
}
64+
}
65+
]
66+
}
67+
}
68+
},
69+
"MaxConcurrency": 20,
70+
"Parameters": {
71+
"FunctionName.$": "$.FunctionName",
72+
"ItemId.$": "$$.Map.Item.Value"
73+
}
74+
}
75+
}
76+
}

0 commit comments

Comments
 (0)