Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make AWS Step function Parameter Optional

Is there a way to make AWS Step function parameter optional? or accept an expression to say if the value is passed pick the value else default it to a certain value?

Example:

Lets say my Parameters are defined as follows:

"Parameters": {
        "comment": "Selecting what I care about.",
        "MyDetails": {
          "size.$": "$.inputSize"
        }
      },

If I don't pass inputSize, the step function fails. is there a way to make this an optional parameter or have an expression like inputSize || 10 where 10 would be picked if nothing is passed

like image 857
Raj Avatar asked Apr 17 '26 20:04

Raj


1 Answers

Short answer is NO.

Two things to note about Step Function state input/output and state InputPath/OutputPath

  1. Input processing doesn't support default property values. All the properties have to come either from the previous state or as input to step function invocation. (Input and Output processing)
  2. JsonPath can be used only to reference a property in InputPath or OutputPath. If a poperty is not present in the input or result an error is thrown. (Reference Paths)

Suggestion

My suggestion is to set the inputSize property to zero or a negative number either in previous state or during step function invocation (don't forget to pass it along various intermediate states). Then you can have a choice state where you can take different routes in your workflow depending upon the value of the inputSize property.

Another way could be to have a mandatory boolean property which tells if a particular property is present or not in the input or result. This can be helpful in the case we want to check for nullness of a property and take different routes in the workflow.

like image 140
Hammad Akhtar Avatar answered Apr 20 '26 09:04

Hammad Akhtar