I’ve been playing trying to prove the concept of getting Lambda Step functions running in Parallel via Serverless. Everything seems to be correct when deploying and then invoking via the command line, but i’m getting a couple of unexpected things when trying to trigger via http.
Via command line, if I run:
serverless invoke stepf -n searchsteps --stage prod
I get a response which shows the parallel functions worked:
{ executionArn: 'arn:aws:states:us-east-1:964191066451:execution:search-steps:339e4a1b-732f-4844-abcf-5d8605a33561',
stateMachineArn: 'arn:aws:states:us-east-1:964191066451:stateMachine:search-steps',
name: '339e4a1b-732f-4844-abcf-5d8605a33561',
status: 'SUCCEEDED',
startDate: 2018-06-25T09:50:20.470Z,
stopDate: 2018-06-25T09:50:22.904Z,
input: '{}',
output: '{"statusCode":200,"results":[{"api1":{"name":"Parking A","id":1,"price":50,"date":"2018-07-15"}},{"api2":{"name":"Parking B","id":2,"price":75,"date":"2018-07-15"}}]}' }
Now for the anomalies, at the end of the deploy i’m being shown what seems to be a wrong endpoint:
Serverless StepFunctions OutPuts
endpoints:
GET - https://w08l6t9sy0.execute-api.us-east-1.amazonaws.com/prodamazonaws.com/prod/search
In reality, I believe the correct endpoint is actually:
https://w08l6t9sy0.execute-api.us-east-1.amazonaws.com/prod/search
If I try and go to the endpoint it doesn’t seem to be triggering the Step Functions correctly … or at least not waiting for the full response. Instead i’m just getting:
{"executionArn":"arn:aws:states:us-east-1:964191066451:execution:search-steps:2cec5ed5-785d-11e8-84fa-53723643d791","startDate":1.529920221652E9}
I’d love any thoughts … i’m struggling
Cheers!
UPDATE:
I’ve realised with further reading that the Step Functions are acting as designed. They are asynchronous and therefore the API Gateway is simply triggering the start of a Step Function and i’d need to use other methods to be notified of a completion etc. Invoking using the command line on the other hand isn’t going through the API Gateway and as it’s command line must be setup to wait for the response. Everything days a school day!
The only issue then is I believe the ‘serverless-step-functions’ plugin may be messing up the endpoint urls (just when displaying in the command line), but i’ll log a bug on Github for that