Skip to content

Commit 84fbd14

Browse files
Adding opensearch vpcendpoints functionality.
Removing unused var from packages.
1 parent 55571a7 commit 84fbd14

File tree

2 files changed

+57
-3
lines changed

2 files changed

+57
-3
lines changed

resources/opensearchservice-packages.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ import (
77
)
88

99
type OSPackage struct {
10-
svc *opensearchservice.OpenSearchService
11-
domainName *string
12-
packageID *string
10+
svc *opensearchservice.OpenSearchService
11+
packageID *string
1312
}
1413

1514
func init() {
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package resources
2+
3+
import (
4+
"github.com/aws/aws-sdk-go/aws/session"
5+
"github.com/aws/aws-sdk-go/service/opensearchservice"
6+
"github.com/rebuy-de/aws-nuke/v2/pkg/types"
7+
)
8+
9+
type OSVPCEndpoint struct {
10+
svc *opensearchservice.OpenSearchService
11+
vpcEndpointId *string
12+
}
13+
14+
func init() {
15+
register("OSVPCEndpoint", ListOSVPCEndpoints)
16+
}
17+
18+
func ListOSVPCEndpoints(sess *session.Session) ([]Resource, error) {
19+
svc := opensearchservice.New(sess)
20+
21+
listResp, err := svc.DescribeVpcEndpoints(&opensearchservice.DescribeVpcEndpointsInput{
22+
VpcEndpointIds: []*string{},
23+
})
24+
if err != nil {
25+
return nil, err
26+
}
27+
28+
resources := make([]Resource, 0)
29+
30+
for _, vpcEndpoint := range listResp.VpcEndpoints {
31+
resources = append(resources, &OSVPCEndpoint{
32+
svc: svc,
33+
vpcEndpointId: vpcEndpoint.VpcEndpointId,
34+
})
35+
}
36+
37+
return resources, nil
38+
}
39+
40+
func (o *OSVPCEndpoint) Remove() error {
41+
_, err := o.svc.DeleteVpcEndpoint(&opensearchservice.DeleteVpcEndpointInput{
42+
VpcEndpointId: o.vpcEndpointId,
43+
})
44+
45+
return err
46+
}
47+
48+
func (o *OSVPCEndpoint) Properties() types.Properties {
49+
properties := types.NewProperties()
50+
return properties
51+
}
52+
53+
func (o *OSVPCEndpoint) String() string {
54+
return *o.vpcEndpointId
55+
}

0 commit comments

Comments
 (0)