Let's say I define a task state that invokes a Lambda. I'm wondering if there's a way I can pass through or default a specific optional input parameter in the Parameters property.
"someState": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"Parameters": {
"FunctionName": "someFunction",
"InvocationType": "RequestResponse",
"Qualifier.$": "$.environmentId",
"Payload": {
"environmentId.$": "$.environmentId",
"someParameter.$": "$.someParameter",
}
}
}
If someParameter is included in the input I want it to be passed through. Else I'd want one of:
• Omit it.
• Be able to configure a default for it.
• Or if it even defaulted to null automatically, that'd be workable for me.
Is there a way to do that?
What actually happens is an error like:
{
"error": "States.Runtime",
"cause": "An error occurred while executing the state 'someState' (entered at the event id #7). The JSONPath '$.someParameter' specified for the field 'someParameter.$' could not be found in the input"
}
Consider this scenario: I have application environments staging and production that execute the step function. someFunction has aliases with those names.
I want someFunction to utilize a new request parameter that will be passed in the input to the step function.
The first thing that will happen is the Lambda code deployed to the staging alias will be updated to utilize the new parameter and the application running in the staging environment will pass it to the step function.
At this point the application running in the production environment will not have been updated to pass the new parameter to the step function.
So if I can just optionally pass through the new parameter, all would be well. But in reality it would break the production environment.
So far the best solution I can think of is to change to...
"Payload": "$"
...to pass everything through and pick out the parameters I'm interested in in the Lambda, but it means passing unnecessary data and the state configuration no longer documents the expected parameters.
Edited by: Jesse12345 on Nov 12, 2019 1:26 PM
Edited by: Jesse12345 on Nov 13, 2019 6:22 AM
This is not presently possible and is my most wanted feature for step functions. You can do tricks with the
Passstate and the transient functionStates.JsonMergebut it's terribly inconvenient.