From dd12098589133801dea4bee307d6591db74dd5b0 Mon Sep 17 00:00:00 2001 From: Likitha Vemulapalli Date: Tue, 26 Apr 2022 11:20:57 -0500 Subject: [PATCH 1/2] Fix AWS Health Event Bridge Rule --- README.md | 2 +- pkg/monitor/sqsevent/scheduled-change-event.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7176f70e..7b3cb487 100644 --- a/README.md +++ b/README.md @@ -329,7 +329,7 @@ $ aws events put-targets --rule MyK8sInstanceStateChangeRule \ $ aws events put-rule \ --name MyK8sScheduledChangeRule \ - --event-pattern "{\"source\": [\"aws.health\"],\"detail-type\": [\"AWS Health Event\"]}" + --event-pattern "{\"source\": [\"aws.health\"],\"detail-type\": [\"AWS Health Event\"],\"detail\": {\"service\": [\"EC2\"],\"eventTypeCategory\": [\"scheduledChange\"]}}" $ aws events put-targets --rule MyK8sScheduledChangeRule \ --targets "Id"="1","Arn"="arn:aws:sqs:us-east-1:123456789012:MyK8sTermQueue" diff --git a/pkg/monitor/sqsevent/scheduled-change-event.go b/pkg/monitor/sqsevent/scheduled-change-event.go index acd2c9fe..43e48ce3 100644 --- a/pkg/monitor/sqsevent/scheduled-change-event.go +++ b/pkg/monitor/sqsevent/scheduled-change-event.go @@ -76,13 +76,13 @@ func (m SQSMonitor) scheduledEventToInterruptionEvents(event *EventBridgeEvent, } if scheduledChangeEventDetail.Service != "EC2" { - err := fmt.Errorf("events from Amazon EventBridge for service (%s) are not supported", scheduledChangeEventDetail.Service) - return append(interruptionEventWrappers, InterruptionEventWrapper{nil, err}) + log.Warn().Msgf("events from Amazon EventBridge for service (%s) are not supported", scheduledChangeEventDetail.Service) + return append(interruptionEventWrappers, InterruptionEventWrapper{nil, nil}) } if scheduledChangeEventDetail.EventTypeCategory != "scheduledChange" { - err := fmt.Errorf("events from Amazon EventBridge with EventTypeCategory (%s) are not supported", scheduledChangeEventDetail.EventTypeCategory) - return append(interruptionEventWrappers, InterruptionEventWrapper{nil, err}) + log.Warn().Msgf("events from Amazon EventBridge with EventTypeCategory (%s) are not supported", scheduledChangeEventDetail.EventTypeCategory) + return append(interruptionEventWrappers, InterruptionEventWrapper{nil, nil}) } for _, affectedEntity := range scheduledChangeEventDetail.AffectedEntities { From 39d8c07fee714ee2e4739f089c3dec99e2a332c4 Mon Sep 17 00:00:00 2001 From: Likitha Vemulapalli Date: Wed, 27 Apr 2022 16:52:14 -0500 Subject: [PATCH 2/2] Fix AWS Health Event Bridge Rule --- pkg/monitor/sqsevent/scheduled-change-event.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/monitor/sqsevent/scheduled-change-event.go b/pkg/monitor/sqsevent/scheduled-change-event.go index 43e48ce3..41adfbf4 100644 --- a/pkg/monitor/sqsevent/scheduled-change-event.go +++ b/pkg/monitor/sqsevent/scheduled-change-event.go @@ -76,13 +76,13 @@ func (m SQSMonitor) scheduledEventToInterruptionEvents(event *EventBridgeEvent, } if scheduledChangeEventDetail.Service != "EC2" { - log.Warn().Msgf("events from Amazon EventBridge for service (%s) are not supported", scheduledChangeEventDetail.Service) - return append(interruptionEventWrappers, InterruptionEventWrapper{nil, nil}) + err := skip{fmt.Errorf("events from Amazon EventBridge for service (%s) are not supported", scheduledChangeEventDetail.Service)} + return append(interruptionEventWrappers, InterruptionEventWrapper{nil, err}) } if scheduledChangeEventDetail.EventTypeCategory != "scheduledChange" { - log.Warn().Msgf("events from Amazon EventBridge with EventTypeCategory (%s) are not supported", scheduledChangeEventDetail.EventTypeCategory) - return append(interruptionEventWrappers, InterruptionEventWrapper{nil, nil}) + err := skip{fmt.Errorf("events from Amazon EventBridge with EventTypeCategory (%s) are not supported", scheduledChangeEventDetail.EventTypeCategory)} + return append(interruptionEventWrappers, InterruptionEventWrapper{nil, err}) } for _, affectedEntity := range scheduledChangeEventDetail.AffectedEntities {