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

CL-807 Adding support for Glue features. #22

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
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
67 changes: 67 additions & 0 deletions resources/glue-blueprints.go
Original file line number Diff line number Diff line change
@@ -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
}
67 changes: 67 additions & 0 deletions resources/glue-ml-transforms.go
Original file line number Diff line number Diff line change
@@ -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
}
67 changes: 67 additions & 0 deletions resources/glue-sessions.go
Original file line number Diff line number Diff line change
@@ -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
}
67 changes: 67 additions & 0 deletions resources/glue-workflows.go
Original file line number Diff line number Diff line change
@@ -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
}
Loading