Skip to content

Commit 42ab697

Browse files
dilip0515dependabot[bot]der-eismannmdirkseOliver Fletcher
authored
Merge upstream (#21)
* Bump the golang group with 1 update (rebuy-de#1188) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump the golang group with 1 update (rebuy-de#1191) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add release note config (rebuy-de#1192) * Add support for Redshift Serverless namespaces, snapshots and workgroups. (rebuy-de#1194) * feat: Adding Cloudfront response headers policies (rebuy-de#1140) * Bump the golang group with 1 update (rebuy-de#1195) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add ELB Listener Rules object (rebuy-de#1193) Co-authored-by: Philipp Trulson <der-eismann@users.noreply.github.com> * Bump the golang group with 2 updates (rebuy-de#1201) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump the golang group with 1 update (rebuy-de#1205) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add manual trigger to workflow (rebuy-de#1208) * Bump the golang group across 1 directory with 2 updates (rebuy-de#1217) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump github.com/aws/aws-sdk-go from 1.51.31 to 1.52.3 in the golang group (rebuy-de#1220) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump the golang group across 1 directory with 2 updates (rebuy-de#1227) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump github.com/aws/aws-sdk-go from 1.53.10 to 1.53.15 in the golang group (rebuy-de#1229) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add cloudformationiface mock (#19) --------- Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Philipp Trulson <der-eismann@users.noreply.github.com> Co-authored-by: Maarten Dirkse <maarten.dirkse@gmail.com> Co-authored-by: Oliver Fletcher <oliver.fletcher@rackspace.com> Co-authored-by: Vincent Boulineau <58430298+vboulineau@users.noreply.github.com> Co-authored-by: Bradley Fisher <brad.fisher25@gmail.com>
1 parent 0b0a317 commit 42ab697

11 files changed

+492
-30
lines changed

.github/release.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes#configuring-automatically-generated-release-notes
2+
3+
changelog:
4+
categories:
5+
- title: Notable changes
6+
labels:
7+
- '*'
8+
exclude:
9+
labels:
10+
- dependencies
11+
- title: Dependency updates
12+
labels:
13+
- dependencies

.github/workflows/ci.yaml

+8-7
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ on:
77
types: [opened, reopened, synchronize]
88
schedule:
99
- cron: '15 3 * * 0'
10+
workflow_dispatch:
1011

1112
jobs:
1213
build:
1314
name: CI Build
1415
runs-on: ubuntu-22.04
1516
steps:
1617
- name: Setup Go
17-
uses: actions/setup-go@v3
18+
uses: actions/setup-go@v5
1819
with:
19-
go-version: '1.21'
20+
go-version: '1.22'
2021
- name: Setup tools
2122
run: |
2223
go install golang.org/x/lint/golint@latest
@@ -61,30 +62,30 @@ jobs:
6162
- name: Set up QEMU
6263
if: github.event_name != 'pull_request'
6364
id: qemu
64-
uses: docker/setup-qemu-action@v2
65+
uses: docker/setup-qemu-action@v3
6566
with:
6667
platforms: arm64
6768

6869
- name: Set up Docker Buildx
69-
uses: docker/setup-buildx-action@v2
70+
uses: docker/setup-buildx-action@v3
7071
with:
7172
install: true
7273

7374
- name: Login to Docker Hub
74-
uses: docker/login-action@v2
75+
uses: docker/login-action@v3
7576
with:
7677
username: ${{ secrets.DOCKER_USERNAME }}
7778
password: ${{ secrets.DOCKER_PASSWORD }}
7879

7980
- name: Login to Quay.io
80-
uses: docker/login-action@v2
81+
uses: docker/login-action@v3
8182
with:
8283
registry: quay.io
8384
username: ${{ secrets.QUAY_USERNAME }}
8485
password: ${{ secrets.QUAY_PASSWORD }}
8586

8687
- name: Build and push
87-
uses: docker/build-push-action@v3
88+
uses: docker/build-push-action@v5
8889
with:
8990
context: .
9091
push: true

.github/workflows/release.yaml

+8-8
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
sed -r -i "s/aws-nuke:v[0-9]+\.[0-9]+\.[0-9]+/aws-nuke:${{ github.ref_name }}/" README.md
2323
sed -r -i "s/aws-nuke-v[0-9]+\.[0-9]+\.[0-9]+/aws-nuke-${{ github.ref_name }}/" README.md
2424
sed -r -i "s/\/v[0-9]+\.[0-9]+\.[0-9]+\//\/${{ github.ref_name }}\//" README.md
25-
- uses: peter-evans/create-pull-request@v5
25+
- uses: peter-evans/create-pull-request@v6
2626
name: Create Pull Request
2727
with:
2828
title: Update readme for ${{ github.ref_name }} release
@@ -36,9 +36,9 @@ jobs:
3636
runs-on: ubuntu-22.04
3737
steps:
3838
- name: Setup Go
39-
uses: actions/setup-go@v3
39+
uses: actions/setup-go@v5
4040
with:
41-
go-version: '1.21'
41+
go-version: '1.22'
4242
- name: Checkout code
4343
uses: actions/checkout@v4
4444
with:
@@ -73,30 +73,30 @@ jobs:
7373

7474
- name: Set up QEMU
7575
id: qemu
76-
uses: docker/setup-qemu-action@v2
76+
uses: docker/setup-qemu-action@v3
7777
with:
7878
platforms: arm64
7979

8080
- name: Set up Docker Buildx
81-
uses: docker/setup-buildx-action@v2
81+
uses: docker/setup-buildx-action@v3
8282
with:
8383
install: true
8484

8585
- name: Login to Docker Hub
86-
uses: docker/login-action@v2
86+
uses: docker/login-action@v3
8787
with:
8888
username: ${{ secrets.DOCKER_USERNAME }}
8989
password: ${{ secrets.DOCKER_PASSWORD }}
9090

9191
- name: Login to Quay.io
92-
uses: docker/login-action@v2
92+
uses: docker/login-action@v3
9393
with:
9494
registry: quay.io
9595
username: ${{ secrets.QUAY_USERNAME }}
9696
password: ${{ secrets.QUAY_PASSWORD }}
9797

9898
- name: Build and push
99-
uses: docker/build-push-action@v3
99+
uses: docker/build-push-action@v5
100100
with:
101101
context: .
102102
push: true

go.mod

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ module github.com/rebuy-de/aws-nuke/v2
33
go 1.21
44

55
require (
6-
github.com/aws/aws-sdk-go v1.50.6
7-
github.com/fatih/color v1.16.0
6+
github.com/aws/aws-sdk-go v1.53.15
7+
github.com/fatih/color v1.17.0
88
github.com/golang/mock v1.6.0
99
github.com/google/uuid v1.6.0
1010
github.com/mb0/glob v0.0.0-20160210091149-1eb79d2de6c4
1111
github.com/pkg/errors v0.9.1
1212
github.com/rebuy-de/rebuy-go-sdk/v4 v4.5.1
1313
github.com/sirupsen/logrus v1.9.3
1414
github.com/spf13/cobra v1.8.0
15-
github.com/stretchr/testify v1.8.4
16-
golang.org/x/sync v0.6.0
15+
github.com/stretchr/testify v1.9.0
16+
golang.org/x/sync v0.7.0
1717
gopkg.in/yaml.v3 v3.0.1
1818
)
1919

@@ -28,7 +28,7 @@ require (
2828
github.com/pmezard/go-difflib v1.0.0 // indirect
2929
github.com/spf13/pflag v1.0.5 // indirect
3030
golang.org/x/mod v0.9.0 // indirect
31-
golang.org/x/sys v0.14.0 // indirect
31+
golang.org/x/sys v0.18.0 // indirect
3232
golang.org/x/tools v0.7.0 // indirect
3333
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
3434
)

go.sum

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
github.com/aws/aws-sdk-go v1.50.6 h1:FaXvNwHG3Ri1paUEW16Ahk9zLVqSAdqa1M3phjZR35Q=
2-
github.com/aws/aws-sdk-go v1.50.6/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
1+
github.com/aws/aws-sdk-go v1.53.15 h1:FtZmkg7xM8RfP2oY6p7xdKBYrRgkITk9yve2QV7N938=
2+
github.com/aws/aws-sdk-go v1.53.15/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
33
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
44
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
55
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
66
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
77
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
8-
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
9-
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
8+
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
9+
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
1010
github.com/gemnasium/logrus-graylog-hook/v3 v3.1.0 h1:SLtCnpI5ZZaz4l7RSatEhppB1BBhUEu+DqGANJzJdEA=
1111
github.com/gemnasium/logrus-graylog-hook/v3 v3.1.0/go.mod h1:wi1zWv9tIvyLSMLCAzgRP+YR24oLVQVBHfPPKjtht44=
1212
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
@@ -52,8 +52,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
5252
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
5353
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
5454
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
55-
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
56-
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
55+
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
56+
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
5757
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
5858
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
5959
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
@@ -68,8 +68,8 @@ golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
6868
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
6969
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
7070
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
71-
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
72-
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
71+
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
72+
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
7373
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
7474
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
7575
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -79,8 +79,8 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc
7979
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
8080
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
8181
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
82-
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
83-
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
82+
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
83+
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
8484
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
8585
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
8686
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package resources
2+
3+
import (
4+
"fmt"
5+
"strings"
6+
7+
"github.com/aws/aws-sdk-go/aws/session"
8+
"github.com/aws/aws-sdk-go/service/cloudfront"
9+
"github.com/rebuy-de/aws-nuke/v2/pkg/types"
10+
)
11+
12+
type CloudFrontResponseHeadersPolicy struct {
13+
svc *cloudfront.CloudFront
14+
ID *string
15+
name *string
16+
}
17+
18+
func init() {
19+
register("CloudFrontResponseHeadersPolicy", ListCloudFrontResponseHeadersPolicies)
20+
}
21+
22+
func ListCloudFrontResponseHeadersPolicies(sess *session.Session) ([]Resource, error) {
23+
svc := cloudfront.New(sess)
24+
resources := []Resource{}
25+
params := &cloudfront.ListResponseHeadersPoliciesInput{}
26+
27+
for {
28+
resp, err := svc.ListResponseHeadersPolicies(params)
29+
if err != nil {
30+
return nil, err
31+
}
32+
33+
for _, item := range resp.ResponseHeadersPolicyList.Items {
34+
resources = append(resources, &CloudFrontResponseHeadersPolicy{
35+
svc: svc,
36+
ID: item.ResponseHeadersPolicy.Id,
37+
name: item.ResponseHeadersPolicy.ResponseHeadersPolicyConfig.Name,
38+
})
39+
}
40+
41+
if resp.ResponseHeadersPolicyList.NextMarker == nil {
42+
break
43+
}
44+
45+
params.Marker = resp.ResponseHeadersPolicyList.NextMarker
46+
}
47+
48+
return resources, nil
49+
}
50+
51+
func (f *CloudFrontResponseHeadersPolicy) Filter() error {
52+
if strings.HasPrefix(*f.name, "Managed-") {
53+
return fmt.Errorf("Cannot delete default CloudFront Response headers policy")
54+
}
55+
return nil
56+
}
57+
58+
func (f *CloudFrontResponseHeadersPolicy) Remove() error {
59+
resp, err := f.svc.GetResponseHeadersPolicy(&cloudfront.GetResponseHeadersPolicyInput{
60+
Id: f.ID,
61+
})
62+
if err != nil {
63+
return err
64+
}
65+
66+
_, err = f.svc.DeleteResponseHeadersPolicy(&cloudfront.DeleteResponseHeadersPolicyInput{
67+
Id: f.ID,
68+
IfMatch: resp.ETag,
69+
})
70+
71+
return err
72+
}
73+
74+
func (f *CloudFrontResponseHeadersPolicy) String() string {
75+
return *f.name
76+
}
77+
78+
func (f *CloudFrontResponseHeadersPolicy) Properties() types.Properties {
79+
properties := types.NewProperties()
80+
properties.Set("ID", f.ID)
81+
properties.Set("Name", f.name)
82+
return properties
83+
}

0 commit comments

Comments
 (0)