diff --git a/resources/glue-blueprints.go b/resources/glue-blueprints.go new file mode 100644 index 000000000..b40ab8dfc --- /dev/null +++ b/resources/glue-blueprints.go @@ -0,0 +1,67 @@ +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 GlueBlueprint struct { + svc *glue.Glue + name *string +} + +func init() { + register("GlueBlueprint", ListGlueBlueprints) +} + +func ListGlueBlueprints(sess *session.Session) ([]Resource, error) { + svc := glue.New(sess) + resources := []Resource{} + + params := &glue.ListBlueprintsInput{ + MaxResults: aws.Int64(25), + } + + for { + output, err := svc.ListBlueprints(params) + if err != nil { + return nil, err + } + + for _, blueprint := range output.Blueprints { + resources = append(resources, &GlueBlueprint{ + svc: svc, + name: blueprint, + }) + } + + if output.NextToken == nil { + break + } + + params.NextToken = output.NextToken + } + + return resources, nil +} + +func (f *GlueBlueprint) Remove() error { + _, err := f.svc.DeleteBlueprint(&glue.DeleteBlueprintInput{ + Name: f.name, + }) + + return err +} + +func (f *GlueBlueprint) Properties() types.Properties { + properties := types.NewProperties() + properties.Set("Name", f.name) + + return properties +} + +func (f *GlueBlueprint) String() string { + return *f.name +} diff --git a/resources/glue-ml-transforms.go b/resources/glue-ml-transforms.go new file mode 100644 index 000000000..67fdee302 --- /dev/null +++ b/resources/glue-ml-transforms.go @@ -0,0 +1,67 @@ +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 GlueMLTransform struct { + svc *glue.Glue + id *string +} + +func init() { + register("GlueMLTransform", ListGlueMLTransforms) +} + +func ListGlueMLTransforms(sess *session.Session) ([]Resource, error) { + svc := glue.New(sess) + resources := []Resource{} + + params := &glue.ListMLTransformsInput{ + MaxResults: aws.Int64(100), + } + + for { + output, err := svc.ListMLTransforms(params) + if err != nil { + return nil, err + } + + for _, transformId := range output.TransformIds { + resources = append(resources, &GlueMLTransform{ + svc: svc, + id: transformId, + }) + } + + if output.NextToken == nil { + break + } + + params.NextToken = output.NextToken + } + + return resources, nil +} + +func (f *GlueMLTransform) Remove() error { + _, err := f.svc.DeleteMLTransform(&glue.DeleteMLTransformInput{ + TransformId: f.id, + }) + + return err +} + +func (f *GlueMLTransform) Properties() types.Properties { + properties := types.NewProperties() + properties.Set("Id", f.id) + + return properties +} + +func (f *GlueMLTransform) String() string { + return *f.id +} diff --git a/resources/glue-sessions.go b/resources/glue-sessions.go new file mode 100644 index 000000000..6dd719ade --- /dev/null +++ b/resources/glue-sessions.go @@ -0,0 +1,67 @@ +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 GlueSession struct { + svc *glue.Glue + id *string +} + +func init() { + register("GlueSession", ListGlueSessions) +} + +func ListGlueSessions(sess *session.Session) ([]Resource, error) { + svc := glue.New(sess) + resources := []Resource{} + + params := &glue.ListSessionsInput{ + MaxResults: aws.Int64(25), + } + + for { + output, err := svc.ListSessions(params) + if err != nil { + return nil, err + } + + for _, session := range output.Sessions { + resources = append(resources, &GlueSession{ + svc: svc, + id: session.Id, + }) + } + + if output.NextToken == nil { + break + } + + params.NextToken = output.NextToken + } + + return resources, nil +} + +func (f *GlueSession) Remove() error { + _, err := f.svc.DeleteSession(&glue.DeleteSessionInput{ + Id: f.id, + }) + + return err +} + +func (f *GlueSession) Properties() types.Properties { + properties := types.NewProperties() + properties.Set("Id", f.id) + + return properties +} + +func (f *GlueSession) String() string { + return *f.id +} diff --git a/resources/glue-workflows.go b/resources/glue-workflows.go new file mode 100644 index 000000000..b7b5a7ab4 --- /dev/null +++ b/resources/glue-workflows.go @@ -0,0 +1,67 @@ +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 GlueWorkflow struct { + svc *glue.Glue + name *string +} + +func init() { + register("GlueWorkflow", ListGlueWorkflows) +} + +func ListGlueWorkflows(sess *session.Session) ([]Resource, error) { + svc := glue.New(sess) + resources := []Resource{} + + params := &glue.ListWorkflowsInput{ + MaxResults: aws.Int64(25), + } + + for { + output, err := svc.ListWorkflows(params) + if err != nil { + return nil, err + } + + for _, workflowName := range output.Workflows { + resources = append(resources, &GlueWorkflow{ + svc: svc, + name: workflowName, + }) + } + + if output.NextToken == nil { + break + } + + params.NextToken = output.NextToken + } + + return resources, nil +} + +func (f *GlueWorkflow) Remove() error { + _, err := f.svc.DeleteWorkflow(&glue.DeleteWorkflowInput{ + Name: f.name, + }) + + return err +} + +func (f *GlueWorkflow) Properties() types.Properties { + properties := types.NewProperties() + properties.Set("Name", f.name) + + return properties +} + +func (f *GlueWorkflow) String() string { + return *f.name +}