Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #327 from rebuy-de/change-error-handling
Browse files Browse the repository at this point in the history
filter SNS errors if operation is not supported in given region
  • Loading branch information
svenwltr authored Feb 11, 2019
2 parents 5a08cc7 + f6b25e5 commit 4eb457b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions resources/sns-endpoints.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package resources

import (
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/sns"
)
Expand All @@ -24,6 +25,13 @@ func ListSNSEndpoints(sess *session.Session) ([]Resource, error) {
for {
resp, err := svc.ListPlatformApplications(platformParams)
if err != nil {
awsErr, ok := err.(awserr.Error)
if ok && awsErr.Code() == "InvalidAction" && awsErr.Message() == "Operation (ListPlatformApplications) is not supported in this region" {
// AWS answers with InvalidAction on regions that do not
// support ListPlatformApplications.
break
}

return nil, err
}

Expand Down
8 changes: 8 additions & 0 deletions resources/sns-platformapplications.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package resources

import (
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/sns"
)
Expand All @@ -23,6 +24,13 @@ func ListSNSPlatformApplications(sess *session.Session) ([]Resource, error) {
for {
resp, err := svc.ListPlatformApplications(params)
if err != nil {
awsErr, ok := err.(awserr.Error)
if ok && awsErr.Code() == "InvalidAction" && awsErr.Message() == "Operation (ListPlatformApplications) is not supported in this region" {
// AWS answers with InvalidAction on regions that do not
// support ListPlatformApplications.
break
}

return nil, err
}

Expand Down

0 comments on commit 4eb457b

Please sign in to comment.