diff --git a/pkg/monitor/sqsevent/sqs-monitor.go b/pkg/monitor/sqsevent/sqs-monitor.go index 7dea9308..95560bf1 100644 --- a/pkg/monitor/sqsevent/sqs-monitor.go +++ b/pkg/monitor/sqsevent/sqs-monitor.go @@ -358,11 +358,28 @@ func (m SQSMonitor) getNodeInfo(instanceID string) (*NodeInfo, error) { }, }) if err != nil { + // handle all kinds of InvalidInstanceID error events + // - https://docs.aws.amazon.com/AWSEC2/latest/APIReference/errors-overview.html + if aerr, ok := err.(awserr.Error); ok && aerr.Code() == "InvalidInstanceID" { + msg := fmt.Sprintf("Invalid instance id %s provided", instanceID) + log.Warn().Msg(msg) + return nil, skip{fmt.Errorf(msg)} + } if aerr, ok := err.(awserr.Error); ok && aerr.Code() == "InvalidInstanceID.NotFound" { msg := fmt.Sprintf("No instance found with instance-id %s", instanceID) log.Warn().Msg(msg) return nil, skip{fmt.Errorf(msg)} } + if aerr, ok := err.(awserr.Error); ok && aerr.Code() == "InvalidInstanceID.Malformed" { + msg := fmt.Sprintf("Malformed instance-id %s", instanceID) + log.Warn().Msg(msg) + return nil, skip{fmt.Errorf(msg)} + } + if aerr, ok := err.(awserr.Error); ok && aerr.Code() == "InvalidInstanceID.NotLinkable" { + msg := fmt.Sprintf("Instance-id %s not linkable", instanceID) + log.Warn().Msg(msg) + return nil, skip{fmt.Errorf(msg)} + } return nil, err } if len(result.Reservations) == 0 || len(result.Reservations[0].Instances) == 0 {