File tree Expand file tree Collapse file tree 3 files changed +37
-5
lines changed Expand file tree Collapse file tree 3 files changed +37
-5
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,16 @@ func (n *Nuke) Run() error {
63
63
return err
64
64
}
65
65
66
+ if n .items .Count (ItemStateFailed ) > 0 && n .items .Count (ItemStateNew ) == 0 {
67
+ for _ , item := range n .items {
68
+ if item .State != ItemStateFailed {
69
+ continue
70
+ }
71
+ logrus .Error (fmt .Sprintf ("%s. %s." , item .Type , item .Reason ))
72
+ }
73
+ return fmt .Errorf ("failed" )
74
+ }
75
+
66
76
if n .items .Count (ItemStateNew ) == 0 {
67
77
fmt .Println ("No resource to delete." )
68
78
return nil
@@ -249,9 +259,14 @@ func (n *Nuke) HandleQueue() {
249
259
n .HandleRemove (item )
250
260
item .Print ()
251
261
case ItemStateFailed :
252
- n .HandleRemove (item )
253
- n .HandleWait (item , listCache )
254
- item .Print ()
262
+ // item.Resource will be nil if an exception was thrown while retrieving cloudControl
263
+ // resourceType's items (I.E resourceTypes lister()), however we still pass down the
264
+ // reason and state so we aren't ignoring these exceptions.
265
+ if item .Resource != nil {
266
+ n .HandleRemove (item )
267
+ n .HandleWait (item , listCache )
268
+ item .Print ()
269
+ }
255
270
case ItemStatePending :
256
271
n .HandleWait (item , listCache )
257
272
item .State = ItemStateWaiting
Original file line number Diff line number Diff line change @@ -5,14 +5,15 @@ import (
5
5
"fmt"
6
6
"runtime/debug"
7
7
8
+ "github.com/aws/aws-sdk-go/aws/awserr"
8
9
"github.com/rebuy-de/aws-nuke/v2/pkg/awsutil"
9
10
"github.com/rebuy-de/aws-nuke/v2/pkg/util"
10
11
"github.com/rebuy-de/aws-nuke/v2/resources"
11
12
log "github.com/sirupsen/logrus"
12
13
"golang.org/x/sync/semaphore"
13
14
)
14
15
15
- const ScannerParallelQueries = 2
16
+ const ScannerParallelQueries = 16
16
17
17
18
func Scan (region * Region , resourceTypes []string ) <- chan * Item {
18
19
s := & scanner {
@@ -72,6 +73,20 @@ func (s *scanner) list(region *Region, resourceType string) {
72
73
return
73
74
}
74
75
76
+ awsErr , ok := err .(awserr.Error )
77
+ if ok && awsErr .Code () == "ThrottlingException" {
78
+ s .items <- & Item {
79
+ Region : region ,
80
+ Resource : nil ,
81
+ State : ItemStateFailed ,
82
+ Reason : err .Error (),
83
+ Type : resourceType ,
84
+ }
85
+ dump := util .Indent (fmt .Sprintf ("%v" , err ), " " )
86
+ log .Errorf ("Listing %s failed:\n %s" , resourceType , dump )
87
+ return
88
+ }
89
+
75
90
dump := util .Indent (fmt .Sprintf ("%v" , err ), " " )
76
91
log .Errorf ("Listing %s failed:\n %s" , resourceType , dump )
77
92
return
Original file line number Diff line number Diff line change @@ -37,9 +37,11 @@ func init() {
37
37
registerCloudControl ("AWS::NetworkFirewall::RuleGroup" )
38
38
}
39
39
40
+ const CloudControlAPiMaxRetries = 5
41
+
40
42
func NewListCloudControlResource (typeName string ) func (* session.Session ) ([]Resource , error ) {
41
43
return func (sess * session.Session ) ([]Resource , error ) {
42
- svc := cloudcontrolapi .New (sess )
44
+ svc := cloudcontrolapi .New (sess , & aws. Config { MaxRetries : aws . Int ( CloudControlAPiMaxRetries )} )
43
45
44
46
params := & cloudcontrolapi.ListResourcesInput {
45
47
TypeName : aws .String (typeName ),
You can’t perform that action at this time.
0 commit comments