2

I have two step functions that run in third one(nested step functions). When first one finishes it creates JSON with a lot of key value information. I want to use this JSON as is in next step function. Currently, output from first step function is escaped string. Is there any nice way to do this, without executing lambda to parse this escaped json string?

1

3 Answers 3

1

You could

  1. Unescape the string in the Lambda that produces it
  2. Have a separate lambda which only escapes (your suggestion)
  3. Escape it in the lambda that consumes it

I would go with 2. considering single responsibility principle, but if you want to avoid another lambda invocation, go with 1. or 3.

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

Comments

0

You can use :2 option when you invoke second step function. That will return a json instead of escape string.

{  
   "Type":"Task",
   "Resource":"arn:aws:states:::states:startExecution.sync:2",
   "Parameters":{  
      "Input":{
        "Comment": "Your input goes here",
        "AWS_STEP_FUNCTIONS_STARTED_BY_EXECUTION_ID.$": "$$.Execution.Id"
       },
      "StateMachineArn":"arn:aws:states:us-east-1:123456789012:stateMachine:NestedStateMachine",
      "Name":"ExecutionName"
   },
   "End":true
}

Source: https://docs.aws.amazon.com/step-functions/latest/dg/connect-stepfunctions.html

Comments

0

We can remove the escape string by converting the output of your step in ResultSelector using "States.StringToJson($), where $ is your output JSON.

This removes escape chars and returns the JSON object.

Hope this helps. For details refer to the Intrinsic Functions

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.