Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add module to handle Glue security configurations #26

Merged
merged 2 commits into from
May 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions resources/glue-securityconfigurations.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package resources

import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/glue"
"github.com/rebuy-de/aws-nuke/v2/pkg/types"
)

type GlueSecurityConfiguration struct {
svc *glue.Glue
name *string
}

func init() {
register("GlueSecurityConfiguration", ListGlueSecurityConfigurations)
}

func ListGlueSecurityConfigurations(sess *session.Session) ([]Resource, error) {
svc := glue.New(sess)
resources := []Resource{}

params := &glue.GetSecurityConfigurationsInput{
MaxResults: aws.Int64(25),
}

for {
output, err := svc.GetSecurityConfigurations(params)
if err != nil {
return nil, err
}

for _, securityConfiguration := range output.SecurityConfigurations {
resources = append(resources, &GlueSecurityConfiguration{
svc: svc,
name: securityConfiguration.Name,
})
}

// Check if there are more security configurations to fetch
if output.NextToken == nil || *output.NextToken == "" {
break
}

params.NextToken = output.NextToken
}

return resources, nil
}

func (f *GlueSecurityConfiguration) Remove() error {
_, err := f.svc.DeleteSecurityConfiguration(&glue.DeleteSecurityConfigurationInput{
Name: f.name,
})

return err
}

func (f *GlueSecurityConfiguration) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("Name", f.name)

return properties
}

func (f *GlueSecurityConfiguration) String() string {
return *f.name
}
Loading