Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the Output JSON data returned from a nested Step Function

Im creating a POC with nested Step Functions (SF) and have hit the following issue.

  • I have SF A that has a sync task that starts the execution of SF B (using the recently announced syntax) & waits for it to complete.
  • SF B returns a valid JSON output
  • In SF A, I can see (from the output of the task that calls SF B) the correct fields returned. e.g Status, ExecutionArn as well as the Output.
  • I then want to execute a Choice Task in SF A that uses a field returned from SF B. However the json in the Output field returned from SF B is escaped json, so the jsonPath isn't able to extract a field from the output data from the nested json.

Is there something im missing or a recommended approach to this scenario? I could "process" the escaped json string in a lambda or something but using it in the Choice task... but that kinda defeats the point of the nested SF workflow somewhat.

Any help appreciated.

like image 961
mbragg02 Avatar asked Aug 29 '19 07:08

mbragg02


People also ask

How do you find the output of a step function?

To get the function output from a Step Function, you have to add a second method in API Gateway which will call the Step Function with the DescribeExecution action. The API Gateway client will have to call this periodically (poll) until the returned status is no longer "RUNNING".

How do you pass data between Step Functions?

You can give AWS Step Functions initial input data by passing it to a StartExecution action when you start an execution, or by passing initial data using the Step Functions console . Initial data is passed to the state machine's StartAt state. If no input is provided, the default is an empty object ( {} ).

What is ResultSelector?

Use the ResultSelector field to manipulate a state's result before ResultPath is applied. The ResultSelector field lets you create a collection of key value pairs, where the values are static or selected from the state's result.


Video Answer


2 Answers

Not sure it's new since you asked the question but the answer is in the link you provided: Use "arn:aws:states:::states:startExecution.sync:2" in the task resource field instead of "arn:aws:states:::states:startExecution.sync"

state output type table

like image 140
Gnarik Avatar answered Oct 19 '22 09:10

Gnarik


I ran into the same issue. I used "OutputPath": "$.Output" at first and that returned the escaped json. I removed that and added "ResultPath": "$.Output", This works, it returns the output as json including the escaped version. Its ok for now until AWS addresses this.

like image 1
catiyeh Avatar answered Oct 19 '22 10:10

catiyeh