Skip to content

Commit d03f1b7

Browse files
ekristencorybekk
authored andcommitted
feat(neptune-instance): support properties and tags
1 parent e0c5e31 commit d03f1b7

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

resources/neptune-instances.go renamed to resources/neptune-instance.go

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ package resources
33
import (
44
"context"
55

6+
"github.com/sirupsen/logrus"
7+
68
"github.com/aws/aws-sdk-go/aws"
79
"github.com/aws/aws-sdk-go/service/neptune"
810

911
"github.com/ekristen/libnuke/pkg/registry"
1012
"github.com/ekristen/libnuke/pkg/resource"
13+
"github.com/ekristen/libnuke/pkg/types"
1114

1215
"github.com/ekristen/aws-nuke/v3/pkg/nuke"
1316
)
@@ -47,9 +50,22 @@ func (l *NeptuneInstanceLister) List(_ context.Context, o interface{}) ([]resour
4750
}
4851

4952
for _, dbInstance := range output.DBInstances {
53+
var dbTags []*neptune.Tag
54+
tags, err := svc.ListTagsForResource(&neptune.ListTagsForResourceInput{
55+
ResourceName: dbInstance.DBInstanceArn,
56+
})
57+
if err != nil {
58+
logrus.WithError(err).Warn("failed to list tags for resource")
59+
}
60+
if tags.TagList != nil {
61+
dbTags = tags.TagList
62+
}
63+
5064
resources = append(resources, &NeptuneInstance{
51-
svc: svc,
52-
ID: dbInstance.DBInstanceIdentifier,
65+
svc: svc,
66+
ID: dbInstance.DBInstanceIdentifier,
67+
Name: dbInstance.DBName,
68+
Tags: dbTags,
5369
})
5470
}
5571

@@ -64,19 +80,25 @@ func (l *NeptuneInstanceLister) List(_ context.Context, o interface{}) ([]resour
6480
}
6581

6682
type NeptuneInstance struct {
67-
svc *neptune.Neptune
68-
ID *string
83+
svc *neptune.Neptune
84+
ID *string
85+
Name *string
86+
Tags []*neptune.Tag
6987
}
7088

71-
func (f *NeptuneInstance) Remove(_ context.Context) error {
72-
_, err := f.svc.DeleteDBInstance(&neptune.DeleteDBInstanceInput{
73-
DBInstanceIdentifier: f.ID,
89+
func (r *NeptuneInstance) Remove(_ context.Context) error {
90+
_, err := r.svc.DeleteDBInstance(&neptune.DeleteDBInstanceInput{
91+
DBInstanceIdentifier: r.ID,
7492
SkipFinalSnapshot: aws.Bool(true),
7593
})
7694

7795
return err
7896
}
7997

80-
func (f *NeptuneInstance) String() string {
81-
return *f.ID
98+
func (r *NeptuneInstance) Properties() types.Properties {
99+
return types.NewPropertiesFromStruct(r)
100+
}
101+
102+
func (r *NeptuneInstance) String() string {
103+
return *r.ID
82104
}

0 commit comments

Comments
 (0)