anantab / serverless-plugin-ifelse

A Serverless Plugin to write If Else conditions in serverless YAML file
69 stars 21 forks source link

Only one of ElseExclude ElseSet gets executed when the condition is FALSE #20

Closed HayDegha0917 closed 4 years ago

HayDegha0917 commented 4 years ago

Added the following to my Serevrless template.

If: '${self:custom.account.es_num_az} > 1'
      Set:
        - resources.Resources.OCSElasticsearchCluster.Properties.ElasticsearchClusterConfig.ZoneAwarenessEnabled: true
        - resources.Resources.OCSElasticsearchCluster.Properties.ElasticsearchClusterConfig.ZoneAwarenessConfig.AvailabilityZoneCount: ${self:custom.account.es_num_az}
      ElseExclude:
        - resources.Resources.OCSElasticsearchCluster.Properties.ElasticsearchClusterConfig.ZoneAwarenessConfig.AvailabilityZoneCount
        - resources.Resources.OCSElasticsearchCluster.Properties.ElasticsearchClusterConfig.ZoneAwarenessConfig
      ElseSet:
        - resources.Resources.OCSElasticsearchCluster.Properties.ElasticsearchClusterConfig.ZoneAwarenessEnabled: false

But the output is:

Serverless: serverless-plugin-ifelse - (1 > 1) Condition not true.
Serverless: serverless-plugin-ifelse - Excluding: resources.Resources.OCSElasticsearchCluster.Properties.ElasticsearchClusterConfig.ZoneAwarenessConfig.AvailabilityZoneCount
Serverless: serverless-plugin-ifelse - Excluding: resources.Resources.OCSElasticsearchCluster.Properties.ElasticsearchClusterConfig.ZoneAwarenessConfig

and if I look at the generated template, I see the ElseSet never gets executed.

HayDegha0917 commented 4 years ago

After looking at it some more, it appears that the sub-nodes of Set and ElseSet are keys but the sub-nodes of Exlude and ElseExclude are arrays. This is freaking confusing!