I need to expand InputPath of Step Functions state with a new property without changing the structure of the initial InputPath.
For instance, my InputPath looks like:
{
"key1": "value1",
"key2": "value2"
}
I need to add here a new pair of key/value and pass this to Lambda. Thus, what I want to have is:
{
"key1": "value1",
"key2": "value2",
"key3": "value3"
}
But I haven't found the way how to implement this. What I was able to do is to change the structure of InputPath using Parameters:
"InputPath": "$",
"Parameters": {
"input.$": "$",
"newValue": "value3"
}
So I get JSON with the following structure:
{
"input": {
"key1": "value1",
"key2": "value2"
},
"key3": "value3"
}
It's not a big problem, but I wonder if there is a way to keep a flat structure of InputPath and not to add new attributes (like "input" in my example).
UPD: I'm aware that it can be implemented using Pass states, but state machine is going to become too massive then.
If you do not know the input parameters, you can use JsonMerge intrinsic function
States.JsonMerge($, States.StringToJson(States.Format('\\{\"{}\": \"{}\"\\}', $.key2, $.value3)), false)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With