Skip to content

Commit 07813a5

Browse files
authored
Merge pull request #830 from oreillymedia/neptune-snapshot-type-bugfix
fix(neptune-snapshot): add filter to exclude automated snapshots
2 parents 3f2065e + 89947aa commit 07813a5

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

docs/resources/neptune-snapshot.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ NeptuneSnapshot
1616

1717
- `CreateTime`: No Description
1818
- `ID`: No Description
19+
- `SnapshotType`: No Description
1920
- `Status`: No Description
2021

2122
!!! note - Using Properties

resources/neptune-snapshot.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package resources
22

33
import (
44
"context"
5+
"fmt"
56
"time"
67

78
"github.com/aws/aws-sdk-go/aws" //nolint:staticcheck
@@ -54,10 +55,11 @@ func (l *NeptuneSnapshotLister) List(_ context.Context, o interface{}) ([]resour
5455

5556
for _, dbClusterSnapshot := range output.DBClusterSnapshots {
5657
resources = append(resources, &NeptuneSnapshot{
57-
svc: svc,
58-
ID: dbClusterSnapshot.DBClusterSnapshotIdentifier,
59-
Status: dbClusterSnapshot.Status,
60-
CreateTime: dbClusterSnapshot.SnapshotCreateTime,
58+
svc: svc,
59+
ID: dbClusterSnapshot.DBClusterSnapshotIdentifier,
60+
Status: dbClusterSnapshot.Status,
61+
SnapshotType: dbClusterSnapshot.SnapshotType,
62+
CreateTime: dbClusterSnapshot.SnapshotCreateTime,
6163
})
6264
}
6365

@@ -72,10 +74,18 @@ func (l *NeptuneSnapshotLister) List(_ context.Context, o interface{}) ([]resour
7274
}
7375

7476
type NeptuneSnapshot struct {
75-
svc *neptune.Neptune
76-
ID *string
77-
Status *string
78-
CreateTime *time.Time
77+
svc *neptune.Neptune
78+
ID *string
79+
Status *string
80+
SnapshotType *string
81+
CreateTime *time.Time
82+
}
83+
84+
func (r *NeptuneSnapshot) Filter() error {
85+
if *r.SnapshotType == "automated" {
86+
return fmt.Errorf("cannot delete automated snapshots")
87+
}
88+
return nil
7989
}
8090

8191
func (r *NeptuneSnapshot) Remove(_ context.Context) error {

0 commit comments

Comments
 (0)