The API Gateway Integration with StepFunction is an asynchronous call with StartExecution.
You invoke the statemachine by providing an arn, something like below, provided you have created necessary resources:
curl -X POST -d '{"input": "{}","name": "MyExecution","stateMachineArn": "arn:aws:states:us-east-1:123456789012:stateMachine:HelloWorld"}' https://a1b2c3d4e5.execute-api.us-east-1.amazonaws.com/alpha/execution
The execution ARN and its epoch date are returned, as shown in the following example.
{
"executionArn":"arn:aws:states:us-east-1:123456789012:execution:HelloWorld:MyExecution",
"startDate":1.486772644911E9
}
I assume you have created another endpoint in API for DescribeExecution, where you provide the above executionArn
and fetch the result of the execution. Something like below:
$ curl -s -X POST -d '{"executionArn": "arn:aws:states:eu-central-1:1234567890:execution:mystatemachine:MyExecution10"}' https://1234abcdef.execute-api.eu-central-1.amazonaws.com/v1/getexecution|jq .
{
"executionArn": "arn:aws:states:eu-central-1:1234567890:execution:mystatemachine:MyExecution10",
"input": "{}",
"inputDetails": {
"__type": "com.amazonaws.swf.base.model#CloudWatchEventsExecutionDataDetails",
"included": true
},
"name": "MyExecution10",
"output": ""This is a fallback from a custom Lambda function exception"",
"outputDetails": {
"__type": "com.amazonaws.swf.base.model#CloudWatchEventsExecutionDataDetails",
"included": true
},
"startDate": 1612006859.079,
"stateMachineArn": "arn:aws:states:eu-central-1:1234567890:stateMachine:mystatemachine",
"status": "SUCCEEDED",
"stopDate": 1612006859.279,
"traceHeader": "Root=1-601545cb-2ca62e87242d4cf21724f7e4;Sampled=1"
}
And as you can see, I am getting the correct message from the CatchFallback
.
My State Machine execution and corresponding output generated by CatchFallback
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…