How to check if a parameter is greater than (or less than) another parameter in AWS CloudFormation?

Viewed 442

So, there are these three parameters that I have in my template:

  DesiredCapacityASG:
    Description: Desired capacity for the auto scaling group
    Type: String
    Default: 3

  MinimumCapacityASG:
    Description: Minimum capacity for the auto scaling group
    Type: String
    Default: 1

  MaximumCapacityASG:
    Description: Maximum capacity for the auto scaling group
    Type: String
    Default: 5

I just want to validate whether DesiredCapacityASG lies between MinCapacityASG and MaxCapacityASG.

I believe this can be achieved using CloudFormation Rules, but there is no intrinsic function for greater than or less than.

I am aware that stack creation would fail if the desired capacity is not between min capacity and max capacity, but I don't want that, I want to validate the parameter itself, like if I wanted to validate my InstanceType parameter I would have done it like this:

"Fn::Contains" : [
  ["m1.large", "m1.small"], {"Ref" : "InstanceType"}
]
0 Answers
Related