-
-
Notifications
You must be signed in to change notification settings - Fork 353
/
ses_configuration_set.go
68 lines (55 loc) · 1.81 KB
/
ses_configuration_set.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package resources
import (
"context"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ses"
"github.com/gruntwork-io/cloud-nuke/config"
"github.com/gruntwork-io/cloud-nuke/logging"
"github.com/gruntwork-io/cloud-nuke/report"
"github.com/gruntwork-io/go-commons/errors"
)
// Returns a formatted string of ses-configuration set names
func (s *SesConfigurationSet) getAll(c context.Context, configObj config.Config) ([]*string, error) {
// Remove default route table, that will be deleted along with its TransitGateway
param := &ses.ListConfigurationSetsInput{}
result, err := s.Client.ListConfigurationSets(param)
if err != nil {
return nil, errors.WithStackTrace(err)
}
var setnames []*string
for _, set := range result.ConfigurationSets {
if configObj.SESConfigurationSet.ShouldInclude(config.ResourceValue{Name: set.Name}) {
setnames = append(setnames, set.Name)
}
}
return setnames, nil
}
// Deletes all sets
func (s *SesConfigurationSet) nukeAll(sets []*string) error {
if len(sets) == 0 {
logging.Debugf("No SES configuration sets to nuke in region %s", s.Region)
return nil
}
logging.Debugf("Deleting all SES configuration sets in region %s", s.Region)
var deletedSets []*string
for _, set := range sets {
_, err := s.Client.DeleteConfigurationSet(&ses.DeleteConfigurationSetInput{
ConfigurationSetName: set,
})
// Record status of this resource
e := report.Entry{
Identifier: aws.StringValue(set),
ResourceType: "SES configuration set",
Error: err,
}
report.Record(e)
if err != nil {
logging.Debugf("[Failed] %s", err)
} else {
deletedSets = append(deletedSets, set)
logging.Debugf("Deleted SES configuration set: %s", *set)
}
}
logging.Debugf("[OK] %d SES configuration set(s) deleted in %s", len(deletedSets), s.Region)
return nil
}