Cloudformation inability to pass in numbers/integers

Hey,

I’ve hit a feature of Cloudformation that is really tripping me up. I would like to pass in a certain variable to an event rule (code below) that is required to be a number, but cf converts everything into a string so I’m unable to do so. Anyone find a workaround for this?

“service”: {
“count”: [
{
“numeric”: [
“>”,
1 # this is the line that must be a number
]
}
]
}

this is the error i receive: Event pattern is not valid. Reason: Value of > must be numeric at

Thanks

Do you get the same error if you reference a Parameter with Type: Number?

I found this issue on GitHub from 2019. Looks like its a known issue but hasn’t been prioritized yet

Unfortunately it will still be converted to a string. From aws documentation…
"Number

An integer or float. AWS CloudFormation validates the parameter value as a number; however, when you use the parameter elsewhere in your template (for example, by using the Ref
intrinsic function), the parameter value becomes a string."

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html

You might not want to hear this. But, you might have to resort to a custom resource and just create it yourself with whichever language SDK you’re comfortable with.

Yeah that’s what I figured but I wanted to try to see if AWS had the support for it. Hopefully in a future update, but it’s frustrating to see it work in the documentation but when you try to use it you get unresolvable errors.

Thanks for your input!

Have you tried YAML?