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

AK
已提問 1 個月前檢視次數 113 次
1 個回答
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
已回答 14 天前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南