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 r53resourceset
Browse files Browse the repository at this point in the history
  • Loading branch information
der-eismann authored Aug 29, 2023
2 parents 8cd1f14 + 7c612f4 commit 9070e8c
Show file tree
Hide file tree
Showing 48 changed files with 1,724 additions and 24 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: '1.20'
go-version: '1.21'
- name: Setup tools
run: |
go install golang.org/x/lint/golint@latest
Expand Down Expand Up @@ -59,6 +59,7 @@ jobs:
id: generate_tags

- name: Set up QEMU
if: github.event_name != 'pull_request'
id: qemu
uses: docker/setup-qemu-action@v2
with:
Expand Down Expand Up @@ -88,4 +89,4 @@ jobs:
context: .
push: true
tags: ${{ steps.generate_tags.outputs.tags }}
platforms: linux/amd64,linux/arm64
platforms: ${{ github.event_name != 'pull_request' && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: '1.20'
go-version: '1.21'
- name: Checkout code
uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20-alpine as builder
FROM golang:1.21-alpine as builder

RUN apk add --no-cache git make curl openssl

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -612,10 +612,10 @@ The easiest way of installing it, is to download the latest
#### Example for Linux Intel/AMD

Download and extract
`$ wget -c https://github.com/rebuy-de/aws-nuke/releases/download/v2.24.1/aws-nuke-v2.24.1-linux-amd64.tar.gz -O - | tar -xz -C $HOME/bin`
`$ wget -c https://github.com/rebuy-de/aws-nuke/releases/download/v2.24.2/aws-nuke-v2.24.2-linux-amd64.tar.gz -O - | tar -xz -C $HOME/bin`

Run
`$ aws-nuke-v2.24.1-linux-amd64`
`$ aws-nuke-v2.24.2-linux-amd64`

### Compile from Source

Expand All @@ -639,7 +639,7 @@ $ docker run \
--rm -it \
-v /full-path/to/nuke-config.yml:/home/aws-nuke/config.yml \
-v /home/user/.aws:/home/aws-nuke/.aws \
quay.io/rebuy/aws-nuke:v2.24.1 \
quay.io/rebuy/aws-nuke:v2.24.2 \
--profile default \
--config /home/aws-nuke/config.yml
```
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module github.com/rebuy-de/aws-nuke/v2

go 1.19
go 1.21

require (
github.com/aws/aws-sdk-go v1.44.323
github.com/aws/aws-sdk-go v1.44.328
github.com/fatih/color v1.15.0
github.com/golang/mock v1.6.0
github.com/google/uuid v1.3.0
github.com/google/uuid v1.3.1
github.com/mb0/glob v0.0.0-20160210091149-1eb79d2de6c4
github.com/pkg/errors v0.9.1
github.com/rebuy-de/rebuy-go-sdk/v4 v4.5.1
Expand Down
11 changes: 7 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/aws/aws-sdk-go v1.44.323 h1:97/dn93DWrN1VfhAWQ2tV+xuE6oO/LO9rSsEsuC4PLU=
github.com/aws/aws-sdk-go v1.44.323/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aws/aws-sdk-go v1.44.328 h1:WBwlf8ym9SDQ/GTIBO9eXyvwappKJyOetWJKl4mT7ZU=
github.com/aws/aws-sdk-go v1.44.328/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/cpuguy83/go-md2man/v2 v2.0.2/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 All @@ -11,8 +11,8 @@ github.com/gemnasium/logrus-graylog-hook/v3 v3.1.0 h1:SLtCnpI5ZZaz4l7RSatEhppB1B
github.com/gemnasium/logrus-graylog-hook/v3 v3.1.0/go.mod h1:wi1zWv9tIvyLSMLCAzgRP+YR24oLVQVBHfPPKjtht44=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
Expand Down Expand Up @@ -71,6 +71,7 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down Expand Up @@ -98,6 +99,7 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
Expand All @@ -112,6 +114,7 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
15 changes: 15 additions & 0 deletions pkg/types/properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@ func (p Properties) SetTagWithPrefix(prefix string, tagKey *string, tagValue int
return p.Set(keyStr, tagValue)
}

func (p Properties) SetPropertyWithPrefix(prefix string, propertyKey string, propertyValue interface{}) Properties {
keyStr := strings.TrimSpace(propertyKey)
prefix = strings.TrimSpace(prefix)

if keyStr == "" {
return p
}

if prefix != "" {
keyStr = fmt.Sprintf("%s:%s", prefix, keyStr)
}

return p.Set(keyStr, propertyValue)
}

func (p Properties) Get(key string) string {
value, ok := p[key]
if !ok {
Expand Down
38 changes: 38 additions & 0 deletions pkg/types/properties_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,41 @@ func TestPropertiesSetTagWithPrefix(t *testing.T) {
})
}
}

func TestPropertiesSetPropertiesWithPrefix(t *testing.T) {
cases := []struct {
name string
prefix string
key string
value interface{}
want string
}{
{
name: "empty",
prefix: "",
key: "OwnerID",
value: aws.String("123456789012"),
want: `[OwnerID: "123456789012"]`,
},
{
name: "nonempty",
prefix: "igw",
key: "OwnerID",
value: aws.String("123456789012"),
want: `[igw:OwnerID: "123456789012"]`,
},
}

for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
p := types.NewProperties()

p.SetPropertyWithPrefix(tc.prefix, tc.key, tc.value)
have := p.String()

if tc.want != have {
t.Errorf("'%s' != '%s'", tc.want, have)
}
})
}
}
10 changes: 10 additions & 0 deletions resources/appconfig-deploymentstrategies.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package resources

import (
"fmt"
"strings"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/appconfig"
Expand Down Expand Up @@ -39,6 +42,13 @@ func ListAppConfigDeploymentStrategies(sess *session.Session) ([]Resource, error
return resources, nil
}

func (f *AppConfigDeploymentStrategy) Filter() error {
if strings.HasPrefix(*f.name, "AppConfig.") {
return fmt.Errorf("cannot delete predefined Deployment Strategy")
}
return nil
}

func (f *AppConfigDeploymentStrategy) Remove() error {
_, err := f.svc.DeleteDeploymentStrategy(&appconfig.DeleteDeploymentStrategyInput{
DeploymentStrategyId: f.id,
Expand Down
62 changes: 62 additions & 0 deletions resources/apprunner-connection.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package resources

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

type AppRunnerConnection struct {
svc *apprunner.AppRunner
ConnectionArn *string
ConnectionName *string
}

func init() {
register("AppRunnerConnection", ListAppRunnerConnections)
}

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

params := &apprunner.ListConnectionsInput{}

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

for _, item := range resp.ConnectionSummaryList {
resources = append(resources, &AppRunnerConnection{
svc: svc,
ConnectionArn: item.ConnectionArn,
ConnectionName: item.ConnectionName,
})
}

if resp.NextToken == nil {
break
}

params.NextToken = resp.NextToken
}

return resources, nil
}

func (f *AppRunnerConnection) Remove() error {
_, err := f.svc.DeleteConnection(&apprunner.DeleteConnectionInput{
ConnectionArn: f.ConnectionArn,
})

return err
}

func (f *AppRunnerConnection) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("ConnectionArn", f.ConnectionArn)
properties.Set("ConnectionName", f.ConnectionName)
return properties
}
65 changes: 65 additions & 0 deletions resources/apprunner-service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package resources

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

type AppRunnerService struct {
svc *apprunner.AppRunner
ServiceArn *string
ServiceId *string
ServiceName *string
}

func init() {
register("AppRunnerService", ListAppRunnerServices)
}

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

params := &apprunner.ListServicesInput{}

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

for _, item := range resp.ServiceSummaryList {
resources = append(resources, &AppRunnerService{
svc: svc,
ServiceArn: item.ServiceArn,
ServiceId: item.ServiceId,
ServiceName: item.ServiceName,
})
}

if resp.NextToken == nil {
break
}

params.NextToken = resp.NextToken
}

return resources, nil
}

func (f *AppRunnerService) Remove() error {
_, err := f.svc.DeleteService(&apprunner.DeleteServiceInput{
ServiceArn: f.ServiceArn,
})

return err
}

func (f *AppRunnerService) Properties() types.Properties {
properties := types.NewProperties()
properties.Set("ServiceArn", f.ServiceArn)
properties.Set("ServiceId", f.ServiceId)
properties.Set("ServiceName", f.ServiceName)
return properties
}
Loading

0 comments on commit 9070e8c

Please sign in to comment.