1

I have created step functions and invoked them as specified in AWS documentation. For output, I am getting

{ 
"executionArn": "arn:aws:states:us-east-1:123456789012:execution:HelloWorld:MyExecution", "startDate": 1385732956.878 
} 

But, instead of above response I want my API response

{ response: DATA}

How can I achieve this?

EDIT: This is the lambda that triggers the state machine:

    import * as AWS from 'aws-sdk';
import {APIGatewayEvent} from 'aws-lambda';

const stepFunctions = new AWS.StepFunctions();

export const handler = (event: APIGatewayEvent) => {
  console.log('event: ' + JSON.stringify(event));
  const stateMachineARN = process.env.MACHINE_ARN;
  const params = {
    stateMachineArn: stateMachineARN,
    input: JSON.stringify(event),
  };
  const request = stepFunctions.startExecution(params);
  request.on('error', err => {
    console.log('aca' + err.message);
  });

  request.send();
};

And the output of the state machine:

{
  "ExecutedVersion": "$LATEST",
  "Payload": {
    "isBase64Encoded": false,
    "statusCode": 200,
    "headers": {},
    "body": {
      "endpoint": {
        "url": "xxx",
        "method": "POST",
        "request": "xxx"
      }
    }
  },

I need to grab that Payload.

3
  • Can you provide the state machine configuration, with sensitive data redacted? Commented Apr 24, 2021 at 5:56
  • How are you getting that output, via which command/function? Are you using a specific SDK? Commented Apr 24, 2021 at 8:15
  • I edited the post with more info Commented Apr 26, 2021 at 14:53

2 Answers 2

2

The DescribeExecution function returns the output of a Step Function.

See: https://docs.aws.amazon.com/step-functions/latest/apireference/API_DescribeExecution.html

How to invoke this will depend on your SDK of choice (AWS CLI, Boto3, Java SDK, etc.)

Sign up to request clarification or add additional context in comments.

Comments

1

If you are using express workflow you can invoke it synchronously to get the result of execution.

For standard workflows you need to use DescribeExecution api from sdk or cli for which input is executionArn.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.