Search code examples
amazon-web-servicesaws-step-functions

Step functions convert string to number


Is there a way in an aws step function to convert a string to a number?

I have a query param that is passed from api gateway to the step function. It is a string with a numeric value. I would like to cast the string to a number in the step function state language, but so far no luck.


Solution

  • There isn't a native solution for Step Functions to achieve this yet. Another workaround would be to use a simple lambda to convert the type.

    Edit: A native workaround would be to use the intrinsic function States.StringToJson

    e.g.

    "NumberValue.$": "States.StringToJson("$.numberAsString")"