This repository was archived by the owner on Oct 15, 2024. It is now read-only.
Commit f197cc3 1 parent d01537a commit f197cc3 Copy full SHA for f197cc3
File tree 2 files changed +132
-0
lines changed
2 files changed +132
-0
lines changed Original file line number Diff line number Diff line change
1
+ package resources
2
+
3
+ import (
4
+ "github.com/aws/aws-sdk-go/aws/session"
5
+ "github.com/aws/aws-sdk-go/service/cloudfront"
6
+ "github.com/rebuy-de/aws-nuke/v2/pkg/types"
7
+ )
8
+
9
+ type CloudFrontKeyGroup struct {
10
+ svc * cloudfront.CloudFront
11
+ ID * string
12
+ }
13
+
14
+ func init () {
15
+ register ("CloudFrontKeyGroup" , ListCloudFrontKeyGroups )
16
+ }
17
+
18
+ func ListCloudFrontKeyGroups (sess * session.Session ) ([]Resource , error ) {
19
+ svc := cloudfront .New (sess )
20
+ resources := []Resource {}
21
+ params := & cloudfront.ListKeyGroupsInput {}
22
+
23
+ for {
24
+ resp , err := svc .ListKeyGroups (params )
25
+ if err != nil {
26
+ return nil , err
27
+ }
28
+
29
+ for _ , item := range resp .KeyGroupList .Items {
30
+ resources = append (resources , & CloudFrontKeyGroup {
31
+ svc : svc ,
32
+ ID : item .KeyGroup .Id ,
33
+ })
34
+ }
35
+
36
+ if resp .KeyGroupList .NextMarker == nil {
37
+ break
38
+ }
39
+
40
+ params .Marker = resp .KeyGroupList .NextMarker
41
+ }
42
+
43
+ return resources , nil
44
+ }
45
+
46
+ func (f * CloudFrontKeyGroup ) Remove () error {
47
+ resp , err := f .svc .GetKeyGroup (& cloudfront.GetKeyGroupInput {
48
+ Id : f .ID ,
49
+ })
50
+ if err != nil {
51
+ return err
52
+ }
53
+
54
+ _ , err = f .svc .DeleteKeyGroup (& cloudfront.DeleteKeyGroupInput {
55
+ Id : f .ID ,
56
+ IfMatch : resp .ETag ,
57
+ })
58
+
59
+ return err
60
+ }
61
+
62
+ func (f * CloudFrontKeyGroup ) Properties () types.Properties {
63
+ properties := types .NewProperties ()
64
+ properties .Set ("ID" , f .ID )
65
+ return properties
66
+ }
Original file line number Diff line number Diff line change
1
+ package resources
2
+
3
+ import (
4
+ "github.com/aws/aws-sdk-go/aws/session"
5
+ "github.com/aws/aws-sdk-go/service/cloudfront"
6
+ "github.com/rebuy-de/aws-nuke/v2/pkg/types"
7
+ )
8
+
9
+ type CloudFrontPublicKey struct {
10
+ svc * cloudfront.CloudFront
11
+ ID * string
12
+ }
13
+
14
+ func init () {
15
+ register ("CloudFrontPublicKey" , ListCloudFrontPublicKeys )
16
+ }
17
+
18
+ func ListCloudFrontPublicKeys (sess * session.Session ) ([]Resource , error ) {
19
+ svc := cloudfront .New (sess )
20
+ resources := []Resource {}
21
+ params := & cloudfront.ListPublicKeysInput {}
22
+
23
+ for {
24
+ resp , err := svc .ListPublicKeys (params )
25
+ if err != nil {
26
+ return nil , err
27
+ }
28
+
29
+ for _ , item := range resp .PublicKeyList .Items {
30
+ resources = append (resources , & CloudFrontPublicKey {
31
+ svc : svc ,
32
+ ID : item .Id ,
33
+ })
34
+ }
35
+
36
+ if resp .PublicKeyList .NextMarker == nil {
37
+ break
38
+ }
39
+
40
+ params .Marker = resp .PublicKeyList .NextMarker
41
+ }
42
+
43
+ return resources , nil
44
+ }
45
+
46
+ func (f * CloudFrontPublicKey ) Remove () error {
47
+ resp , err := f .svc .GetPublicKey (& cloudfront.GetPublicKeyInput {
48
+ Id : f .ID ,
49
+ })
50
+ if err != nil {
51
+ return err
52
+ }
53
+
54
+ _ , err = f .svc .DeletePublicKey (& cloudfront.DeletePublicKeyInput {
55
+ Id : f .ID ,
56
+ IfMatch : resp .ETag ,
57
+ })
58
+
59
+ return err
60
+ }
61
+
62
+ func (f * CloudFrontPublicKey ) Properties () types.Properties {
63
+ properties := types .NewProperties ()
64
+ properties .Set ("ID" , f .ID )
65
+ return properties
66
+ }
You can’t perform that action at this time.
0 commit comments