0

I am starting a step function from Lambda and the Lambda function is tied to an API Gateway. For some reason, when I try to test the Lambda function, I see hundreds of executions failed and running in loop. I just triggered the step function once. I am missing something here. Can you please advise.

enter image description here

enter image description here

const AWS = require("aws-sdk");
const uuidv4 = require("uuid/v4");
/*----------------------------------------------------------------------- */
/* Implementation                                                         */
/*----------------------------------------------------------------------- */
exports.handler = async event => {

  var _dt = await ExecuteStepFunction()
  return _dt;
}

function ExecuteStepFunction() {
  const stepFunctions = new AWS.StepFunctions();
  return new Promise((res, rej) => {
    var params = {
      stateMachineArn: 'arn:aws:states:us-east-1:xxxxxxxxxxxxx:stateMachine:xxTestSateMachine',
      input: JSON.stringify(''),
      name: uuidv4()
    };
    stepFunctions.startExecution(params, function (err, data) {
      if (err) {
        rej(err);
      }
      else {
        res(data);
      }
    });
  });
}

I tried thIS approach provided in the this link (https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-api-gateway.html) where the API gateway directly triggers the step function but I am receiving the following error. After trying to fix this, I move to the above option of starting the function using the API.

{
  "__type": "com.amazon.coral.service#UnrecognizedClientException",
  "message": "The security token included in the request is invalid"
}
Mohan
  • 41
  • 4
  • The number of executions continued and so I had to delete the step function to stop that infinite loop. – Mohan Jul 13 '19 at 15:18
  • Are you sure that the state machine you are using does not include this lambda function? Because this sounds like an infinite loop problem to me. – guzmonne Jul 13 '19 at 15:33
  • @guzmonne I am sure I didnt do that, but I will double check. Thanks for your response. – Mohan Jul 13 '19 at 16:29

0 Answers0