forked from gruntwork-io/cloud-nuke
/
security_hub_types.go
52 lines (41 loc) · 1.14 KB
/
security_hub_types.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
package resources
import (
"context"
"github.com/andrewderr/cloud-nuke-a1/config"
awsgo "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/securityhub"
"github.com/aws/aws-sdk-go/service/securityhub/securityhubiface"
"github.com/gruntwork-io/go-commons/errors"
)
type SecurityHub struct {
Client securityhubiface.SecurityHubAPI
Region string
HubArns []string
}
func (sh *SecurityHub) Init(session *session.Session) {
sh.Client = securityhub.New(session)
}
func (sh *SecurityHub) ResourceName() string {
return "security-hub"
}
func (sh *SecurityHub) ResourceIdentifiers() []string {
return sh.HubArns
}
func (sh *SecurityHub) MaxBatchSize() int {
return 5
}
func (sh *SecurityHub) GetAndSetIdentifiers(c context.Context, configObj config.Config) ([]string, error) {
identifiers, err := sh.getAll(c, configObj)
if err != nil {
return nil, err
}
sh.HubArns = awsgo.StringValueSlice(identifiers)
return sh.HubArns, nil
}
func (sh *SecurityHub) Nuke(identifiers []string) error {
if err := sh.nukeAll(identifiers); err != nil {
return errors.WithStackTrace(err)
}
return nil
}