I would like to compare two input values which are a number but since it is the output of another state machine step from lambda function so it's converted into string values, I want to compare them as a number greater than or equal to and then proceed for other state machine step or terminate it, but it seems not possible to compare them and always going to wrong step.
I have already tried States.FormatNumber and States.StringToJson as suggested in the link: Step functions convert string to number but it didn't work. Is there any way to do it without going to the AWS lambda function to compare it?
e.g: My input is as below:
{
"v2_table": {
"count": "2"
},
"original_table": {
"count": "2"
}
}
AWS Step function is as below:
{
"StartAt": "CompareCounts",
"States": {
"CompareCounts": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.v2_table.count",
"NumericGreaterThanEqualsPath": "$.original_table.count",
"Next": "CountsMatch"
}
],
"Default": "CountsDoNotMatch"
},
"CountsMatch": {
"Type": "Pass",
"End": true
},
"CountsDoNotMatch": {
"Type": "Pass",
"End": true
}
}
}
For the above input, it goes to CountsDoNotMatch which is incorrect. Execution with the above input results as below
Another example is when I tried to compare the numbers with StringGreaterThanEqualsPath and still failed,
Step Function Definition as:
{
"StartAt": "CompareNumberAsString",
"States": {
"CompareNumberAsString": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.argument_one",
"StringGreaterThanEqualsPath": "$.argument_two",
"Next": "ArgumentOneGreaterThanEquals"
}
],
"Default": "ArgumentTwoGreaterThan"
},
"ArgumentOneGreaterThanEquals": {
"Type": "Pass",
"End": true
},
"ArgumentTwoGreaterThan": {
"Type": "Pass",
"End": true
}
}
}
Executed with the below input:
{
"argument_one": "11",
"argument_two": "100"
}
Execution Results which is incorrect as below:
If I changed the comparison with Numeric i.e. NumericGreaterThanEqualsPath in the above step function definition and parameters as numbers then it works as the below, but in my case, input will be number as string data type which is not working.




”i” > “be”and ‘“9” > “11”’. Need to use convert to numerical to get what you want. Equals will probably work great unless one ends with a decimal. Hope that helps. Good luck.