@@ -593,20 +593,26 @@ class AlertsPlugin {
593
593
resourcesKeys . length === 0 ||
594
594
resourcesKeys . indexOf ( resource ) !== - 1 )
595
595
)
596
- . map ( ( key ) => resources [ key ] ) ;
596
+ . map ( ( key ) => ( {
597
+ cfLogicalId : key ,
598
+ cfResource : resources [ key ] ,
599
+ } ) ) ;
597
600
}
598
601
599
- _resolveAlarmsNames ( definition ) {
602
+ _resolveAlarmsPhysicalLogicalIds ( definition ) {
600
603
return this . _getFilteredResourcesAsArray (
601
604
definition . alarmsToInclude ,
602
605
'AWS::CloudWatch::Alarm' ,
603
606
true
604
- ) . map ( ( resource ) => resource . Properties . AlarmName ) ;
607
+ ) . map ( ( filteredResource ) => ( {
608
+ cfLogicalId : filteredResource . cfLogicalId ,
609
+ cfPhysicalId : filteredResource . cfResource . Properties . AlarmName ,
610
+ } ) ) ;
605
611
}
606
612
607
- _resolveAlarmRules ( alarmsNames ) {
608
- const alarmRule = alarmsNames
609
- . map ( ( alarmName ) => `ALARM(${ alarmName } )` )
613
+ _resolveAlarmRules ( physicalLogicalIds ) {
614
+ const alarmRule = physicalLogicalIds
615
+ . map ( ( physicalLogicalId ) => `ALARM(${ physicalLogicalId . cfPhysicalId } )` )
610
616
. join ( ' OR ' ) ;
611
617
612
618
return alarmRule ;
@@ -641,9 +647,10 @@ class AlertsPlugin {
641
647
Object . keys ( definitions ) . forEach ( ( definitionName ) => {
642
648
const definition = definitions [ definitionName ] ;
643
649
if ( definition . type === 'composite' && definition . enabled !== false ) {
644
- const alarmsNames = this . _resolveAlarmsNames ( definition ) ;
650
+ const physicalLogicalIds =
651
+ this . _resolveAlarmsPhysicalLogicalIds ( definition ) ;
645
652
// only create the composite alarm if there is at least one alarm to include
646
- if ( alarmsNames ?. length > 0 ) {
653
+ if ( physicalLogicalIds ?. length > 0 ) {
647
654
const cf = { } ;
648
655
const { cfResource, cfName } = this . _getCfResourceAndName (
649
656
'Composite' ,
@@ -656,10 +663,10 @@ class AlertsPlugin {
656
663
AlarmName : cfName ,
657
664
AlarmDescription : definition . description ,
658
665
ActionsEnabled : definition . actionsEnabled ,
659
- AlarmRule : this . _resolveAlarmRules ( alarmsNames ) ,
666
+ AlarmRule : this . _resolveAlarmRules ( physicalLogicalIds ) ,
660
667
AlarmActions : alarmActions ,
661
668
} ,
662
- DependsOn : alarmsNames ,
669
+ DependsOn : physicalLogicalIds . map ( ( alarm ) => alarm . cfLogicalId ) ,
663
670
} ;
664
671
665
672
cf [ cfResource ] = compositeAlarm ;
0 commit comments