Skip to content

Commit

Permalink
remove old case to have only one alert/handler for wrong arn
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Guibert committed Jun 8, 2021
1 parent d629ffc commit 58d3956
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 30 deletions.
34 changes: 5 additions & 29 deletions pkg/remote/aws/sns_topic_subscription_supplier.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,6 @@ import (
"github.com/cloudskiff/driftctl/pkg/terraform"
)

type pendingTopicAlert struct {
endpoint *string
}

func (p *pendingTopicAlert) Message() string {
return fmt.Sprintf("%s with pending confirmation status for endpoint \"%s\" will be ignored",
aws.AwsSnsTopicSubscriptionResourceType,
awssdk.StringValue(p.endpoint))
}

func (p *pendingTopicAlert) ShouldIgnoreResource() bool {
return false
}

type wrongArnTopicAlert struct {
arn string
endpoint *string
Expand Down Expand Up @@ -90,21 +76,11 @@ func (s *SNSTopicSubscriptionSupplier) Resources() ([]resource.Resource, error)

func (s *SNSTopicSubscriptionSupplier) readTopicSubscription(subscription *sns.Subscription, alertr alerter.AlerterInterface) (cty.Value, error) {
if subscription.SubscriptionArn != nil && !arn.IsARN(*subscription.SubscriptionArn) {
switch *subscription.SubscriptionArn {
case "PendingConfirmation":
alertr.SendAlert(
fmt.Sprintf("%s.%s", aws.AwsSnsTopicSubscriptionResourceType, *subscription.SubscriptionArn),
&pendingTopicAlert{subscription.Endpoint},
)
return cty.NilVal, nil
default:
alertr.SendAlert(
fmt.Sprintf("%s.%s", aws.AwsSnsTopicSubscriptionResourceType, *subscription.SubscriptionArn),
&wrongArnTopicAlert{*subscription.SubscriptionArn, subscription.Endpoint},
)
return cty.NilVal, nil

}
alertr.SendAlert(
fmt.Sprintf("%s.%s", aws.AwsSnsTopicSubscriptionResourceType, *subscription.SubscriptionArn),
&wrongArnTopicAlert{*subscription.SubscriptionArn, subscription.Endpoint},
)
return cty.NilVal, nil
}

val, err := s.reader.ReadResource(terraform.ReadResourceArgs{
Expand Down
2 changes: 1 addition & 1 deletion pkg/remote/aws/sns_topic_subscription_supplier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestSNSTopicSubscriptionSupplier_Resources(t *testing.T) {
},
alerts: map[string][]alerter.Alert{
"aws_sns_topic_subscription.PendingConfirmation": []alerter.Alert{
&pendingTopicAlert{aws.String("TEST")},
&wrongArnTopicAlert{"PendingConfirmation", aws.String("TEST")},
},
"aws_sns_topic_subscription.Incorrect": []alerter.Alert{
&wrongArnTopicAlert{"Incorrect", aws.String("INCORRECT")},
Expand Down

0 comments on commit 58d3956

Please sign in to comment.