Definition:
StartAt: GetElementCount
States:
GetElementCount:
Type: Task
Resource: arn:aws:lambda:::function:some-function
Parameters:
"stateName.$": "$$.State.Name"
"collection.$": "$.collection"
ResultPath: "$.iterator"
Next: CheckIfFinished
CheckIfFinished:
Type: Choice
Choices:
-
Variable: "$.iterator.continue"
BooleanEquals: true
Next: ProcessElement
Default: Done
ProcessElement:
Type: Task
Resource: arn:aws:lambda:::function:some-function
ResultPath: "$.iterator"
Parameters:
"stateName.$": "$$.State.Name"
"collection.$": "$.collection"
"iterator.$": "$.iterator"
Next: WaitABit
Retry:
- ErrorEquals:
- States.TaskFailed
IntervalSeconds: 3
MaxAttempts: 65535
BackoffRate: 1.5
WaitABit:
Type: Wait
Seconds: 10
Next: CheckIfFinished
Done:
Type: Succeed
{
"StateMachines": {
"MySampleStateMachine": {
"TestCases": {
"ProcessingFailsAndGetsRetried": {
"GetElementCount": "InitIteratorState",
"ProcessElement": "ProcessElementStateOneFailure"
}
}
}
},
"MockedResponses": {
"InitIteratorState": {
"0": {
"Return": {
"continue": true,
"count": 3,
"index": 0
}
}
},
"ProcessElementStateOneFailure": {
"0": {
"Throw": {
"Error":"Lambda.TimeoutException",
"Cause":"Lambda timed out."
}
},
"1": {
"Return": {
"continue": true,
"count": 3,
"index": 1
}
},
"2": {
"Return": {
"continue": true,
"count": 3,
"index": 2
}
},
"3": {
"Return": {
"continue": false,
"count": 3,
"index": 3
}
}
}
}
}
....
{
"timestamp": 1650293455.773,
"type": "LambdaFunctionStarted",
"id": 11,
"previousEventId": 10
},
{
"timestamp": 1650293455.773,
"type": "LambdaFunctionFailed",
"id": 12,
"previousEventId": 11,
"lambdaFunctionFailedEventDetails": {
"error": "Lambda.TimeoutException",
"cause": "Lambda timed out."
}
},
{
"timestamp": 1650293458.775,
"type": "LambdaFunctionScheduled",
"id": 13,
"previousEventId": 12,
"lambdaFunctionScheduledEventDetails": {
"resource": "arn:aws:lambda:us-east-1:123456789012:function:some-function",
"input": "{\"iterator\":{\"continue\":true,\"count\":3,\"index\":0},\"stateName\":\"ProcessElement\",\"collection\":[{\"index\":0},{\"index\":1},{\"index\":2}]}",
"inputDetails": {
"truncated": false
}
}
},
...
that I have in my definition.
This makes testcases that test retrying slow. Shouldn't retrying work the same way as WaitTask
and multply the IntervalSeconds
by WAIT_TIME_SCALE
?