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

Add RedshiftScheduledAction resource #1047

Merged
merged 16 commits into from
Aug 24, 2023
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
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
}
Loading