How to use regex in CF template for conditions

461 Views Asked by At

I am using a condition in troposphere CF template, but unfortunately there are more than 10 conditions and AWS CF supports only 10 of them. The condition checks if the app name start with particular name. Is there a way to use regex in condition so I can write only one condition instead of 10, stating do something if the name start with appname*

I am adding the conditions for each role but since aws supports only 10, I cant add more than that.

conditions = {
"RoleEqualCollectors01" :  Equals(
        Ref(ThorRole),
        "collectors01",
           ),

        ...,
        ...,

    "RoleEqualCollectors22" :  Equals(
        Ref(ThorRole),
        "collectors22",
           ),

"Collector" :  Or(
        Condition("RoleEqualCollectors01"),
        ...,
        ...,
        Condition("RoleEqualCollectors22")
    ),

is there a way I can specify like this,

conditions = {
"RoleEqualCollectors" :  Equals(
        Ref(ThorRole),
        "collectors*",
           ),

"Collector" :  Or(
        Condition("RoleEqualCollectors*"),
    ),

1

There are 1 best solutions below

0
On

Just found out that AWS has a limit for Or condition, it needs minimum 2 and maximum 10 conditions, there is a work around, I did three separate Or conditions and then a Final_Or condition that combines all of them. or1: Fn::Or condition for 1,2, 3, 4, 5, 6, 7, 8, 9, 10

or2: Fn::Or condition for 11, 12, 13, 14, 15, 16, 17, 18, 19, 20

or3: Fn::Or condition for 21, 22

Final_Or: Fn::Or for or1, or2, or3