StepFunction - to create array in resultselector

0

I am trying to create a payload definition that should look like - in 1st step which is new tasks.LambdaInvoke

 "StepResult":[
	  "Step1":{				
		"Status" : "Success"
		"Errors": "[{}]",	
		"Message": "Count is 0"
		"StartTimeUTC":
		"EndTimeUTC": 
	  }]

after which i have next step which will invoke an activity - new tasks.StepFunctionsInvokeActivity this also will generate a payload, but I am trying to append that to the step result back, meaning now my step result will have 2 steps which should look like - "StepResult":[ "Step1":{ "Status" : "Success" "Errors": "[{}]", "Message": "Count is 0" "StartTimeUTC": "EndTimeUTC": } "Step2": { "Status": "Success", "Errors": "[{}]", "Message": "Successfully transferred entity'" "StartTimeUTC": "EndTimeUTC": } ]

Can yo help me how can we achieve this using typescript cdk

1 Answer
0

You are looking to manage Input and Output Processing in Step Functions, which uses the InputPath, ResultPath, and OutputPath to manipulate the JSON state payload through the state machine. There are examples here: https://docs.aws.amazon.com/step-functions/latest/dg/input-output-example.html

Your desired output above has keys in an array, which won't work, but you can change StepResult to an object. You would just need to format the Lambda results payload contents, and then use something like resultPath: '$.StepResult.Step1'

Your Lambda steps would be defined in the TypeScript something like this:

const stepOne = new tasks.LambdaInvoke(this, 'Step One', {
  lambdaFunction: getStatusLambda,
  outputPath: '$.Payload',
  resultPath: '$.StepResult.Step1'
});

and your Activity might look something like this:

const submitJobActivity = new sfn.Activity(this, 'StepTwo');

new tasks.StepFunctionsInvokeActivity(this, 'Step Two', {
  activity: submitJobActivity,
  outputPath: '$.Payload',
  resultPath: '$.StepResult.Step2'
});

Note this will preserve the rest of the state payload (JSON) so not exactly the output you describe as the input payload would be merged with the outputs.

AWS
Mike_A
answered 13 hours ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions