Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
Add RedshiftScheduledAction resource (#1047)
Browse files Browse the repository at this point in the history
* Add RedshiftScheduledAction resource

---------

Co-authored-by: Björn Häuser <b.haeuser@rebuy.com>
  • Loading branch information
MikeSchouw and bjoernhaeuser authored Aug 24, 2023
1 parent e641116 commit 150eb13
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions resources/redshift-scheduled-action.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package resources

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

type RedshiftScheduledAction struct {
svc *redshift.Redshift
scheduledActionName *string
}

func init() {
register("RedshiftScheduledAction", ListRedshiftScheduledActions)
}

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

params := &redshift.DescribeScheduledActionsInput{}

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

for _, item := range resp.ScheduledActions {
resources = append(resources, &RedshiftScheduledAction{
svc: svc,
scheduledActionName: item.ScheduledActionName,
})
}

if resp.Marker == nil {
break
}

params.Marker = resp.Marker
}

return resources, nil
}

func (f *RedshiftScheduledAction) Remove() error {

_, err := f.svc.DeleteScheduledAction(&redshift.DeleteScheduledActionInput{
ScheduledActionName: f.scheduledActionName,
})

return err
}

func (f *RedshiftScheduledAction) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("scheduledActionName", f.scheduledActionName)
return properties
}

0 comments on commit 150eb13

Please sign in to comment.