|
| 1 | +package resources |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/aws/aws-sdk-go/aws" |
| 5 | + "github.com/aws/aws-sdk-go/aws/session" |
| 6 | + "github.com/aws/aws-sdk-go/service/glue" |
| 7 | + "github.com/rebuy-de/aws-nuke/v2/pkg/types" |
| 8 | +) |
| 9 | + |
| 10 | +type GlueSecurityConfiguration struct { |
| 11 | + svc *glue.Glue |
| 12 | + name *string |
| 13 | +} |
| 14 | + |
| 15 | +func init() { |
| 16 | + register("GlueSecurityConfiguration", ListGlueSecurityConfigurations) |
| 17 | +} |
| 18 | + |
| 19 | +func ListGlueSecurityConfigurations(sess *session.Session) ([]Resource, error) { |
| 20 | + svc := glue.New(sess) |
| 21 | + resources := []Resource{} |
| 22 | + |
| 23 | + params := &glue.GetSecurityConfigurationsInput{ |
| 24 | + MaxResults: aws.Int64(25), |
| 25 | + } |
| 26 | + |
| 27 | + for { |
| 28 | + output, err := svc.GetSecurityConfigurations(params) |
| 29 | + if err != nil { |
| 30 | + return nil, err |
| 31 | + } |
| 32 | + |
| 33 | + for _, securityConfiguration := range output.SecurityConfigurations { |
| 34 | + resources = append(resources, &GlueSecurityConfiguration{ |
| 35 | + svc: svc, |
| 36 | + name: securityConfiguration.Name, |
| 37 | + }) |
| 38 | + } |
| 39 | + |
| 40 | + // Check if there are more security configurations to fetch |
| 41 | + if output.NextToken == nil || *output.NextToken == "" { |
| 42 | + break |
| 43 | + } |
| 44 | + |
| 45 | + params.NextToken = output.NextToken |
| 46 | + } |
| 47 | + |
| 48 | + return resources, nil |
| 49 | +} |
| 50 | + |
| 51 | +func (f *GlueSecurityConfiguration) Remove() error { |
| 52 | + _, err := f.svc.DeleteSecurityConfiguration(&glue.DeleteSecurityConfigurationInput{ |
| 53 | + Name: f.name, |
| 54 | + }) |
| 55 | + |
| 56 | + return err |
| 57 | +} |
| 58 | + |
| 59 | +func (f *GlueSecurityConfiguration) Properties() types.Properties { |
| 60 | + properties := types.NewProperties() |
| 61 | + properties.Set("Name", f.name) |
| 62 | + |
| 63 | + return properties |
| 64 | +} |
| 65 | + |
| 66 | +func (f *GlueSecurityConfiguration) String() string { |
| 67 | + return *f.name |
| 68 | +} |
0 commit comments