Skip to content

Commit b83c825

Browse files
authored
ignore test notification Event (#640)
1 parent df7f64e commit b83c825

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

pkg/monitor/sqsevent/asg-lifecycle-event.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,16 @@ import (
4848
}
4949
*/
5050

51+
const TEST_NOTIFICATION = "autoscaling:TEST_NOTIFICATION"
52+
5153
// LifecycleDetail provides the ASG lifecycle event details
5254
type LifecycleDetail struct {
5355
LifecycleActionToken string `json:"LifecycleActionToken"`
5456
AutoScalingGroupName string `json:"AutoScalingGroupName"`
5557
LifecycleHookName string `json:"LifecycleHookName"`
5658
EC2InstanceID string `json:"EC2InstanceId"`
5759
LifecycleTransition string `json:"LifecycleTransition"`
60+
Event string `json:"Event"`
5861
RequestID string `json:"RequestId"`
5962
Time string `json:"Time"`
6063
}
@@ -66,7 +69,7 @@ func (m SQSMonitor) asgTerminationToInterruptionEvent(event *EventBridgeEvent, m
6669
return nil, err
6770
}
6871

69-
if lifecycleDetail.LifecycleTransition == "autoscaling:TEST_NOTIFICATION" {
72+
if lifecycleDetail.Event == TEST_NOTIFICATION || lifecycleDetail.LifecycleTransition == TEST_NOTIFICATION {
7073
return nil, skip{fmt.Errorf("message is an ASG test notification")}
7174
}
7275

pkg/monitor/sqsevent/sqs-monitor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func (m SQSMonitor) processLifecycleEventFromASG(message *sqs.Message) (EventBri
136136
log.Err(err).Msg("only lifecycle events from ASG to SQS are supported outside EventBridge")
137137
return eventBridgeEvent, err
138138

139-
case lifecycleEvent.LifecycleTransition == "autoscaling:TEST_NOTIFICATION":
139+
case lifecycleEvent.Event == TEST_NOTIFICATION || lifecycleEvent.LifecycleTransition == TEST_NOTIFICATION:
140140
log.Warn().Msg("ignoring ASG test notification")
141141
return eventBridgeEvent, skip{fmt.Errorf("message is a test notification")}
142142

pkg/monitor/sqsevent/sqs-monitor_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,15 @@ var asgLifecycleTestNotification = sqsevent.EventBridgeEvent{
8989
"arn:aws:autoscaling:us-east-1:123456789012:autoScalingGroup:26e7234b-03a4-47fb-b0a9-2b241662774e:autoScalingGroupName/nth-test1",
9090
},
9191
Detail: []byte(`{
92+
"Event": "autoscaling:TEST_NOTIFICATION",
9293
"LifecycleTransition": "autoscaling:TEST_NOTIFICATION"
9394
}`),
9495
}
9596

9697
var asgLifecycleTestNotificationFromSQS = sqsevent.LifecycleDetail{
9798
LifecycleHookName: "test-nth-asg-to-sqs",
9899
RequestID: "3775fac9-93c3-7ead-8713-159816566000",
100+
Event: "autoscaling:TEST_NOTIFICATION",
99101
LifecycleTransition: "autoscaling:TEST_NOTIFICATION",
100102
AutoScalingGroupName: "my-asg",
101103
Time: "2022-01-31T23:07:47.872Z",

0 commit comments

Comments
 (0)