Skip to content

Commit 17e590e

Browse files
committed
Improving Internal Tools and Documentation (#33)
* docs: add note about continued attribution * chore: improve internal tooling
1 parent 4e0c69b commit 17e590e

File tree

5 files changed

+46
-19
lines changed

5 files changed

+46
-19
lines changed

docs/index.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Remove all resources from an AWS account.
55
*aws-nuke* is stable, but it is likely that not all AWS resources are covered by it. Be encouraged to add missing
66
resources and create a Pull Request or to create an [Issue](https://github.com/ekristen/aws-nuke/issues/new).
77

8-
## History
8+
## History of this Fork
99

1010
This is a full fork of the original tool written by the folks over at [rebuy-de](https://github.com/rebuy-de). This fork became necessary
1111
after attempting to make contributions and respond to issues to learn that the current maintainers only have time to
@@ -16,7 +16,15 @@ decision to fork and maintain it.
1616
Since then the rebuy-de team has taken up interest in responding to their issues and pull requests, but I have decided
1717
to continue maintaining this fork as I have a few things I want to do with it that I don't think they will be interested.
1818

19-
## libnuke
19+
### Continued Attribution
20+
21+
I want to make it clear that I am not trying to take credit for the work of the original authors, and I will continue
22+
to give them credit for their work. I also want to make sure any contributors are also recognized and attributed for
23+
their work. Since this has diverged from the upstream, I've written tooling and scripts to cherry-pick commits from
24+
upstream and apply them to this fork, then modify the resources to work with the new library and submit as a PR to this
25+
fork.
26+
27+
## Introducing libnuke
2028

2129
Officially over the Christmas break of 2023, I decided to create [libnuke](https://github.com/ekristen/libnuke) which
2230
is a library that can be used to create similar tools for other cloud providers. This library is used by both this tool,

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ require (
2525
github.com/mattn/go-isatty v0.0.20 // indirect
2626
github.com/mb0/glob v0.0.0-20160210091149-1eb79d2de6c4 // indirect
2727
github.com/pmezard/go-difflib v1.0.0 // indirect
28+
github.com/rogpeppe/go-internal v1.11.0 // indirect
2829
github.com/russross/blackfriday/v2 v2.1.0 // indirect
2930
github.com/stevenle/topsort v0.2.0 // indirect
3031
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
32+
golang.org/x/net v0.19.0 // indirect
3133
golang.org/x/sync v0.6.0 // indirect
3234
golang.org/x/sys v0.16.0 // indirect
3335
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect

go.sum

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
3939
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
4040
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4141
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
42-
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
4342
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
43+
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
44+
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
4445
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
4546
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
4647
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
@@ -62,8 +63,8 @@ golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
6263
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
6364
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
6465
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
65-
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
66-
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
66+
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
67+
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
6768
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
6869
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
6970
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
@@ -81,8 +82,8 @@ golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
8182
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
8283
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
8384
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
84-
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
85-
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
85+
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
86+
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
8687
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
8788
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
8889
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=

tools/compare-resources/main.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ import (
1313
var OriginalRegisterRegex = regexp.MustCompile("register\\(\"(?P<resource>.*)\",\\s?(?P<function>\\w+)(,)?(\\s+mapCloudControl\\(\"(?P<cc>.*)\"\\))?")
1414
var NewRegisterRegex = regexp.MustCompile(`resource.Registration{\s+Name:\s+(?P<name>.*),`)
1515

16+
var aliases = map[string]string{
17+
"NetpuneSnapshot": "NeptuneSnapshot",
18+
"EKSFargateProfiles": "EKSFargateProfile",
19+
"EKSNodegroups": "EKSNodegroup",
20+
}
21+
1622
func main() {
1723
args := os.Args[1:]
1824

@@ -104,14 +110,22 @@ func main() {
104110

105111
fmt.Println("\nResources not in local aws-nuke:")
106112
for _, resource := range awsNukeResourceTypes {
107-
if !slices.Contains(localResourceTypes, resource) {
113+
_, ok := aliases[resource]
114+
if !slices.Contains(localResourceTypes, resource) && !ok {
108115
fmt.Println("->", resource)
109116
}
110117
}
111118

112119
fmt.Println("\nResources not in aws-nuke:")
113120
for _, resource := range localResourceTypes {
114-
if !slices.Contains(awsNukeResourceTypes, resource) {
121+
found := false
122+
for _, v := range aliases {
123+
if v == resource {
124+
found = true
125+
}
126+
}
127+
128+
if !slices.Contains(awsNukeResourceTypes, resource) && !found {
115129
fmt.Println("+>", resource)
116130
}
117131
}

tools/migrate-resource/main.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,18 @@ func main() {
4141
panic("no arguments given")
4242
}
4343

44+
if len(args) != 2 {
45+
fmt.Println("usage: migrate-resource <source-aws-nuke> <resource-type>")
46+
os.Exit(1)
47+
}
48+
4449
originalSourceDir := filepath.Join(args[0], "resources")
4550

4651
repl := regexp.MustCompile("func init\\(\\) {\\s+.*[\\s+].*\\s}")
4752
match := regexp.MustCompile("register\\(\"(?P<resource>.*)\",\\s?(?P<function>\\w+)(,)?(\\s+mapCloudControl\\(\"(?P<cc>.*)\"\\))?")
4853
funcMatch := regexp.MustCompile("func List.*{")
4954

50-
filename := filepath.Join(originalSourceDir, "resources", args[0]+".go")
55+
filename := filepath.Join(originalSourceDir, "resources", args[1]+".go")
5156

5257
originalFileContents, err := os.ReadFile(filename)
5358
if err != nil {
@@ -60,14 +65,6 @@ func main() {
6065
panic("no matches")
6166
}
6267
resourceType := matches[1]
63-
funcName := matches[2]
64-
cc := ""
65-
if len(matches) == 4 {
66-
cc = matches[3]
67-
}
68-
69-
fmt.Println(cc)
70-
fmt.Println(funcName)
7168

7269
data := struct {
7370
ResourceType string
@@ -107,8 +104,13 @@ func main() {
107104
newContents = strings.ReplaceAll(newContents, "config.FeatureFlags", "*featureflag.FeatureFlags")
108105
newContents = strings.ReplaceAll(newContents, ") Remove() error {", ") Remove(_ context.Context) error {")
109106

107+
cwd, err := os.Getwd()
108+
if err != nil {
109+
panic(err)
110+
}
111+
110112
if err := os.WriteFile(
111-
filepath.Join(".", "resources", args[0]+".go"), []byte(newContents), 0644); err != nil {
113+
filepath.Join(cwd, "resources", args[1]+".go"), []byte(newContents), 0644); err != nil {
112114
panic(err)
113115
}
114116
}

0 commit comments

Comments
 (0)