I have a parameter 'request_id' that I want to have get an ID from two different formats of JSON that get sent to the input of my step function task.
The first form looks like this:
{ "request_id": "abcde-abcd-abcde-abc" }
The second is in this form:
{ "request": { "id": "abcde-abcd-abcde-abc", }
Currently, I have a parameter which looks like
"request_id.$": "$.request_id"
but would like something that is equivalent to (this one does not work)
"request_id.$": "$.['request_id','request.id']"
Is this possible within the step function or will I need to either split those two request id's up into two paths in my JSON or do it in a function?
One workaround could be to have a choice state and check if the first variable present or not:
{
"Variable": "$.request_id",
"IsPresent": true
}
And then two different assignment based on the result.
https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-choice-state.html
{
"StartAt": "choice",
"States": {
"choice": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.request_id",
"IsPresent": true,
"Next": "assignment1"
}
],
"Default": "assignment2"
},
"assignment1": {
"Type": "Pass",
"Result": "World",
"End": true
},
"assignment2": {
"Type": "Pass",
"Result": "World",
"End": true
}
}
}