- Newest
- Most votes
- Most comments
It appears there may be a misunderstanding about how ResultPath works in AWS Step Functions. The behavior you're experiencing is actually the correct implementation of ResultPath.
When you set ResultPath to "$.inventory", you're instructing Step Functions to place the entire input of the state into a new field called "inventory" in the output. This is why you're seeing the original input nested under the "inventory" key.
If you want to achieve the output structure shown in the documentation example, you would need to do the following:
- Use InputPath to pass only the necessary fields to the task (if needed).
- Have your task return only the inventory value (400 in this case).
- Use ResultPath as "$.inventory" to add this result to the original input.
For example, if your task returns just the number 400, then using ResultPath as "$.inventory" would produce the output you're expecting:
{
"product_id": 123,
"region": "east",
"inventory" : 400
}
If you need to manipulate the task output before combining it with the input, you might need to use a combination of ResultSelector and ResultPath, or consider using a Pass state to reshape the data.
Remember, ResultPath determines where in the input the result of the task execution will be placed. If you want to merge specific fields from the task result with the input, you might need to adjust your task to return only those fields or use more complex JsonPath expressions in your state machine definition.
Sources
Gather Amazon S3 bucket info using AWS SDK service integrations - AWS Step Functions
answered 2 years ago
Are you following this example? https://docs.aws.amazon.com/step-functions/latest/dg/input-output-resultpath.html
Relevant content
asked 2 years ago
asked a year ago
- AWS OFFICIALUpdated 2 years ago
