Skip to content

Commit 0c8daf7

Browse files
committed
feat: new resource TransferWebApp
1 parent 96cbeeb commit 0c8daf7

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ require (
4040
github.com/aws/aws-sdk-go-v2/service/ssmquicksetup v1.3.2 // indirect
4141
github.com/aws/aws-sdk-go-v2/service/sso v1.24.8 // indirect
4242
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.7 // indirect
43+
github.com/aws/aws-sdk-go-v2/service/transfer v1.55.1 // indirect
4344
github.com/benbjohnson/clock v1.3.0 // indirect
4445
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
4546
github.com/davecgh/go-spew v1.1.1 // indirect
47+
github.com/iancoleman/strcase v0.3.0 // indirect
4648
github.com/jmespath/go-jmespath v0.4.0 // indirect
4749
github.com/kr/pretty v0.3.1 // indirect
4850
github.com/mattn/go-colorable v0.1.13 // indirect

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.7 h1:F2rBfNAL5UyswqoeWv9zs74N
4040
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.7/go.mod h1:JfyQ0g2JG8+Krq0EuZNnRwX0mU0HrwY/tG6JNfcqh4k=
4141
github.com/aws/aws-sdk-go-v2/service/sts v1.33.3 h1:Xgv/hyNgvLda/M9l9qxXc4UFSgppnRczLxlMs5Ae/QY=
4242
github.com/aws/aws-sdk-go-v2/service/sts v1.33.3/go.mod h1:5Gn+d+VaaRgsjewpMvGazt0WfcFO+Md4wLOuBfGR9Bc=
43+
github.com/aws/aws-sdk-go-v2/service/transfer v1.55.1 h1:bENkaFtA6rxHAwNPjYbgwYxUHGJbL7QocCt8nKZ7d10=
44+
github.com/aws/aws-sdk-go-v2/service/transfer v1.55.1/go.mod h1:C7x9hpm90ZocJ9GbauHMkVMU0m7knEiKhOaa4um9tBU=
4345
github.com/aws/smithy-go v1.22.1 h1:/HPHZQ0g7f4eUeK6HKglFz8uwVfZKgoI25rb/J+dnro=
4446
github.com/aws/smithy-go v1.22.1/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg=
4547
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
@@ -84,6 +86,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
8486
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
8587
github.com/gotidy/ptr v1.4.0 h1:7++suUs+HNHMnyz6/AW3SE+4EnBhupPSQTSI7QNijVc=
8688
github.com/gotidy/ptr v1.4.0/go.mod h1:MjRBG6/IETiiZGWI8LrRtISXEji+8b/jigmj2q0mEyM=
89+
github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
90+
github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
8791
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
8892
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
8993
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=

resources/transfer-web-app.go

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package resources
2+
3+
import (
4+
"context"
5+
6+
"github.com/aws/aws-sdk-go-v2/service/transfer"
7+
8+
"github.com/ekristen/libnuke/pkg/registry"
9+
"github.com/ekristen/libnuke/pkg/resource"
10+
"github.com/ekristen/libnuke/pkg/types"
11+
12+
"github.com/ekristen/aws-nuke/v3/pkg/nuke"
13+
)
14+
15+
const TransferWebAppResource = "TransferWebApp"
16+
17+
func init() {
18+
registry.Register(&registry.Registration{
19+
Name: TransferWebAppResource,
20+
Scope: nuke.Account,
21+
Resource: &TransferWebApp{},
22+
Lister: &TransferWebAppLister{},
23+
})
24+
}
25+
26+
type TransferWebAppLister struct{}
27+
28+
func (l *TransferWebAppLister) List(ctx context.Context, o interface{}) ([]resource.Resource, error) {
29+
opts := o.(*nuke.ListerOpts)
30+
svc := transfer.NewFromConfig(*opts.Config)
31+
var resources []resource.Resource
32+
33+
res, err := svc.ListWebApps(ctx, &transfer.ListWebAppsInput{})
34+
if err != nil {
35+
return nil, err
36+
}
37+
38+
for _, entry := range res.WebApps {
39+
resources = append(resources, &TransferWebApp{
40+
svc: svc,
41+
ID: entry.WebAppId,
42+
})
43+
}
44+
45+
return resources, nil
46+
}
47+
48+
type TransferWebApp struct {
49+
svc *transfer.Client
50+
ID *string
51+
}
52+
53+
func (r *TransferWebApp) Remove(ctx context.Context) error {
54+
_, err := r.svc.DeleteWebApp(ctx, &transfer.DeleteWebAppInput{
55+
WebAppId: r.ID,
56+
})
57+
return err
58+
}
59+
60+
func (r *TransferWebApp) Properties() types.Properties {
61+
return types.NewPropertiesFromStruct(r)
62+
}
63+
64+
func (r *TransferWebApp) String() string {
65+
return *r.ID
66+
}

0 commit comments

Comments
 (0)