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

Commit

Permalink
Merge branch 'main' into feat/cloudfront-response-headers-policies
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Fletcher authored Feb 25, 2024
2 parents b940e06 + 566bb86 commit 44546cb
Show file tree
Hide file tree
Showing 6 changed files with 222 additions and 3 deletions.
13 changes: 13 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes#configuring-automatically-generated-release-notes

changelog:
categories:
- title: Notable changes
labels:
- '*'
exclude:
labels:
- dependencies
- title: Dependency updates
labels:
- dependencies
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/rebuy-de/aws-nuke/v2
go 1.21

require (
github.com/aws/aws-sdk-go v1.50.6
github.com/aws/aws-sdk-go v1.50.21
github.com/fatih/color v1.16.0
github.com/golang/mock v1.6.0
github.com/google/uuid v1.6.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/aws/aws-sdk-go v1.50.6 h1:FaXvNwHG3Ri1paUEW16Ahk9zLVqSAdqa1M3phjZR35Q=
github.com/aws/aws-sdk-go v1.50.6/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/aws/aws-sdk-go v1.50.21 h1:W8awpwiInOt4qHQE6JghRYQJhHcf/cDJS3mlZYqioSQ=
github.com/aws/aws-sdk-go v1.50.21/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
68 changes: 68 additions & 0 deletions resources/redshiftserverless-namespaces.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/redshiftserverless"
"github.com/rebuy-de/aws-nuke/v2/pkg/types"
)

type RedshiftServerlessNamespace struct {
svc *redshiftserverless.RedshiftServerless
namespace *redshiftserverless.Namespace
}

func init() {
register("RedshiftServerlessNamespace", ListRedshiftServerlessNamespaces)
}

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

params := &redshiftserverless.ListNamespacesInput{
MaxResults: aws.Int64(100),
}

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

for _, namespace := range output.Namespaces {
resources = append(resources, &RedshiftServerlessNamespace{
svc: svc,
namespace: namespace,
})
}

if output.NextToken == nil {
break
}

params.NextToken = output.NextToken
}

return resources, nil
}

func (n *RedshiftServerlessNamespace) Properties() types.Properties {
properties := types.NewProperties().
Set("CreationDate", n.namespace.CreationDate).
Set("NamespaceName", n.namespace.NamespaceName)

return properties
}

func (n *RedshiftServerlessNamespace) Remove() error {
_, err := n.svc.DeleteNamespace(&redshiftserverless.DeleteNamespaceInput{
NamespaceName: n.namespace.NamespaceName,
})

return err
}

func (n *RedshiftServerlessNamespace) String() string {
return *n.namespace.NamespaceName
}
69 changes: 69 additions & 0 deletions resources/redshiftserverless-snapshots.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
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/redshiftserverless"
"github.com/rebuy-de/aws-nuke/v2/pkg/types"
)

type RedshiftServerlessSnapshot struct {
svc *redshiftserverless.RedshiftServerless
snapshot *redshiftserverless.Snapshot
}

func init() {
register("RedshiftServerlessSnapshot", ListRedshiftServerlessSnapshots)
}

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

params := &redshiftserverless.ListSnapshotsInput{
MaxResults: aws.Int64(100),
}

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

for _, snapshot := range output.Snapshots {
resources = append(resources, &RedshiftServerlessSnapshot{
svc: svc,
snapshot: snapshot,
})
}

if output.NextToken == nil {
break
}

params.NextToken = output.NextToken
}

return resources, nil
}

func (s *RedshiftServerlessSnapshot) Properties() types.Properties {
properties := types.NewProperties().
Set("CreateTime", s.snapshot.SnapshotCreateTime).
Set("Namespace", s.snapshot.NamespaceName).
Set("SnapshotName", s.snapshot.SnapshotName)

return properties
}

func (s *RedshiftServerlessSnapshot) Remove() error {
_, err := s.svc.DeleteSnapshot(&redshiftserverless.DeleteSnapshotInput{
SnapshotName: s.snapshot.SnapshotName,
})

return err
}

func (s *RedshiftServerlessSnapshot) String() string {
return *s.snapshot.SnapshotName
}
69 changes: 69 additions & 0 deletions resources/redshiftserverless-workgroups.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
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/redshiftserverless"
"github.com/rebuy-de/aws-nuke/v2/pkg/types"
)

type RedshiftServerlessWorkgroup struct {
svc *redshiftserverless.RedshiftServerless
workgroup *redshiftserverless.Workgroup
}

func init() {
register("RedshiftServerlessWorkgroup", ListRedshiftServerlessWorkgroups)
}

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

params := &redshiftserverless.ListWorkgroupsInput{
MaxResults: aws.Int64(100),
}

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

for _, workgroup := range output.Workgroups {
resources = append(resources, &RedshiftServerlessWorkgroup{
svc: svc,
workgroup: workgroup,
})
}

if output.NextToken == nil {
break
}

params.NextToken = output.NextToken
}

return resources, nil
}

func (w *RedshiftServerlessWorkgroup) Properties() types.Properties {
properties := types.NewProperties().
Set("CreationDate", w.workgroup.CreationDate).
Set("Namespace", w.workgroup.NamespaceName).
Set("WorkgroupName", w.workgroup.WorkgroupName)

return properties
}

func (w *RedshiftServerlessWorkgroup) Remove() error {
_, err := w.svc.DeleteWorkgroup(&redshiftserverless.DeleteWorkgroupInput{
WorkgroupName: w.workgroup.WorkgroupName,
})

return err
}

func (w *RedshiftServerlessWorkgroup) String() string {
return *w.workgroup.WorkgroupName
}

0 comments on commit 44546cb

Please sign in to comment.