I'm trying to start the execution of an AWS StepFunction from inside an AWS Lambda, but I receive null as result, with no error message. The StepFunctions here is an Express State Machine, so I use the method startSyncExecution(params = {}, callback), as pointed in the docs.
Here is the code of the Lambda:
const AWS = require('aws-sdk');
exports.handler = async(event, context, callback) => {
var params = {
stateMachineArn: "arn:aws:states:us-east-1:[AccountID]:stateMachine:BookLectureStateMachine",
input: JSON.stringify(event),
name: "test-from-lambda"
}
var stepfunctions = new AWS.StepFunctions();
console.log("Everything okay") //This one is logged
stepfunctions.startSyncExecution(params, function(err, data) {
console.log("This log isn't shown"); //This one isn't logged
if (err) {
callback(null, {
statusCode: 400,
body: err,
headers: {
'Access-Control-Allow-Origin': '*'
}
})
} else {
callback(null, {
statusCode: 200,
body: 'Lecture booked',
headers: {
'Access-Control-Allow-Origin': '*'
}
})
}
});
};
The response is null, nothing else.
I've checked the permissions, and the Lambda has Full Access to the Step Functions.
Any idea on how to solve it?
UPDATE
- I think the StepFunction is not executed, since the logs are empty.
- I increased the Lambda timeout to 1min in order to avoid timeout scenarios. The billed duration is about half a second
async. Since you aren't usingawaitin your handler anywhere, I would try removingasyncfrom the handler. Either that or you could try changing the code tovar data = await stepfunctions.startSyncExecution(params).promise()async. Post it as an answer!