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
|
package resources
import (
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/securityhub"
"github.com/rebuy-de/aws-nuke/pkg/types"
)
func init() {
register("SecurityHub", ListHubs)
}
func ListHubs(sess *session.Session) ([]Resource, error) {
svc := securityhub.New(sess)
resources := make([]Resource, 0)
resp, err := svc.DescribeHub(nil)
if err != nil {
if IsAWSError(err, securityhub.ErrCodeInvalidAccessException) {
// Security Hub is not enabled for this region
return resources, nil
}
return nil, err
}
resources = append(resources, &Hub{
svc: svc,
id: resp.HubArn,
})
return resources, nil
}
type Hub struct {
svc *securityhub.SecurityHub
id *string
}
func (hub *Hub) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("Arn", hub.id)
return properties
}
func (hub *Hub) Remove() error {
_, err := hub.svc.DisableSecurityHub(&securityhub.DisableSecurityHubInput{})
return err
}
|