Skip to content

Commit c7f8113

Browse files
committed
Add resources s3vectors
1 parent ef4faf9 commit c7f8113

12 files changed

+510
-9
lines changed

docs/s3-vectors-bucket.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
generated: true
3+
---
4+
5+
# S3VectorsBucket
6+
7+
8+
## Resource
9+
10+
```text
11+
S3VectorsBucket
12+
```
13+
14+
## Properties
15+
16+
17+
- `ARN`: No Description
18+
- `Name`: No Description
19+
20+
!!! note - Using Properties
21+
Properties are what [Filters](../config-filtering.md) are written against in your configuration. You use the property
22+
names to write filters for what you want to **keep** and omit from the nuke process.
23+
24+
### String Property
25+
26+
The string representation of a resource is generally the value of the Name, ID or ARN field of the resource. Not all
27+
resources support properties. To write a filter against the string representation, simply omit the `property` field in
28+
the filter.
29+
30+
The string value is always what is used in the output of the log format when a resource is identified.
31+
32+
### DependsOn
33+
34+
!!! important - Experimental Feature
35+
This resource depends on a resource using the experimental feature. This means that the resource will
36+
only be deleted if all the resources of a particular type are deleted first or reach a terminal state.
37+
38+
- [S3VectorsIndex](./s3-vectors-index.md)
39+
- [S3VectorsBucketPolicy](./s3-vectors-bucket-policy.md)
40+
41+

docs/s3-vectors-index.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
generated: true
3+
---
4+
5+
# S3VectorsIndex
6+
7+
8+
## Resource
9+
10+
```text
11+
S3VectorsIndex
12+
```
13+
14+
## Properties
15+
16+
17+
- `BucketName`: No Description
18+
- `IndexARN`: No Description
19+
- `IndexName`: No Description
20+
21+
!!! note - Using Properties
22+
Properties are what [Filters](../config-filtering.md) are written against in your configuration. You use the property
23+
names to write filters for what you want to **keep** and omit from the nuke process.
24+
25+
### String Property
26+
27+
The string representation of a resource is generally the value of the Name, ID or ARN field of the resource. Not all
28+
resources support properties. To write a filter against the string representation, simply omit the `property` field in
29+
the filter.
30+
31+
The string value is always what is used in the output of the log format when a resource is identified.
32+
33+
### DependsOn
34+
35+
!!! important - Experimental Feature
36+
This resource depends on a resource using the experimental feature. This means that the resource will
37+
only be deleted if all the resources of a particular type are deleted first or reach a terminal state.
38+
39+
- [S3VectorsVector](./s3-vectors-vector.md)
40+

docs/s3-vectors-vector.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
generated: true
3+
---
4+
5+
# S3VectorsVector
6+
7+
8+
## Resource
9+
10+
```text
11+
S3VectorsVector
12+
```
13+
14+
## Properties
15+
16+
17+
- `IndexName`: No Description
18+
- `Key`: No Description
19+
- `VectorBucketName`: No Description
20+
21+
!!! note - Using Properties
22+
Properties are what [Filters](../config-filtering.md) are written against in your configuration. You use the property
23+
names to write filters for what you want to **keep** and omit from the nuke process.
24+
25+
### String Property
26+
27+
The string representation of a resource is generally the value of the Name, ID or ARN field of the resource. Not all
28+
resources support properties. To write a filter against the string representation, simply omit the `property` field in
29+
the filter.
30+
31+
The string value is always what is used in the output of the log format when a resource is identified.
32+
33+

go.mod

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ toolchain go1.25.3
66

77
require (
88
github.com/aws/aws-sdk-go v1.55.8
9-
github.com/aws/aws-sdk-go-v2 v1.39.3
9+
github.com/aws/aws-sdk-go-v2 v1.39.4
1010
github.com/aws/aws-sdk-go-v2/config v1.28.11
1111
github.com/aws/aws-sdk-go-v2/credentials v1.17.71
1212
github.com/aws/aws-sdk-go-v2/service/amp v1.36.0
@@ -28,6 +28,7 @@ require (
2828
github.com/aws/aws-sdk-go-v2/service/route53profiles v1.4.17
2929
github.com/aws/aws-sdk-go-v2/service/s3 v1.72.3
3030
github.com/aws/aws-sdk-go-v2/service/s3control v1.52.7
31+
github.com/aws/aws-sdk-go-v2/service/s3vectors v1.4.10
3132
github.com/aws/aws-sdk-go-v2/service/shield v1.34.6
3233
github.com/aws/aws-sdk-go-v2/service/ssmquicksetup v1.3.10
3334
github.com/aws/aws-sdk-go-v2/service/sts v1.34.1
@@ -51,8 +52,8 @@ require (
5152
require (
5253
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7 // indirect
5354
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.33 // indirect
54-
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.10 // indirect
55-
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.10 // indirect
55+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.11 // indirect
56+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.11 // indirect
5657
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect
5758
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.27 // indirect
5859
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.0 // indirect

go.sum

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
github.com/aws/aws-sdk-go v1.55.8 h1:JRmEUbU52aJQZ2AjX4q4Wu7t4uZjOu71uyNmaWlUkJQ=
22
github.com/aws/aws-sdk-go v1.55.8/go.mod h1:ZkViS9AqA6otK+JBBNH2++sx1sgxrPKcSzPPvQkUtXk=
3-
github.com/aws/aws-sdk-go-v2 v1.39.3 h1:h7xSsanJ4EQJXG5iuW4UqgP7qBopLpj84mpkNx3wPjM=
4-
github.com/aws/aws-sdk-go-v2 v1.39.3/go.mod h1:yWSxrnioGUZ4WVv9TgMrNUeLV3PFESn/v+6T/Su8gnM=
3+
github.com/aws/aws-sdk-go-v2 v1.39.4 h1:qTsQKcdQPHnfGYBBs+Btl8QwxJeoWcOcPcixK90mRhg=
4+
github.com/aws/aws-sdk-go-v2 v1.39.4/go.mod h1:yWSxrnioGUZ4WVv9TgMrNUeLV3PFESn/v+6T/Su8gnM=
55
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7 h1:lL7IfaFzngfx0ZwUGOZdsFFnQ5uLvR0hWqqhyE7Q9M8=
66
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7/go.mod h1:QraP0UcVlQJsmHfioCrveWOC1nbiWUl3ej08h4mXWoc=
77
github.com/aws/aws-sdk-go-v2/config v1.28.11 h1:7Ekru0IkRHRnSRWGQLnLN6i0o1Jncd0rHo2T130+tEQ=
@@ -10,10 +10,10 @@ github.com/aws/aws-sdk-go-v2/credentials v1.17.71 h1:r2w4mQWnrTMJjOyIsZtGp3R3XGY
1010
github.com/aws/aws-sdk-go-v2/credentials v1.17.71/go.mod h1:E7VF3acIup4GB5ckzbKFrCK0vTvEQxOxgdq4U3vcMCY=
1111
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.33 h1:D9ixiWSG4lyUBL2DDNK924Px9V/NBVpML90MHqyTADY=
1212
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.33/go.mod h1:caS/m4DI+cij2paz3rtProRBI4s/+TCiWoaWZuQ9010=
13-
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.10 h1:mj/bdWleWEh81DtpdHKkw41IrS+r3uw1J/VQtbwYYp8=
14-
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.10/go.mod h1:7+oEMxAZWP8gZCyjcm9VicI0M61Sx4DJtcGfKYv2yKQ=
15-
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.10 h1:wh+/mn57yhUrFtLIxyFPh2RgxgQz/u+Yrf7hiHGHqKY=
16-
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.10/go.mod h1:7zirD+ryp5gitJJ2m1BBux56ai8RIRDykXZrJSp540w=
13+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.11 h1:7AANQZkF3ihM8fbdftpjhken0TP9sBzFbV/Ze/Y4HXA=
14+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.11/go.mod h1:NTF4QCGkm6fzVwncpkFQqoquQyOolcyXfbpC98urj+c=
15+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.11 h1:ShdtWUZT37LCAA4Mw2kJAJtzaszfSHFb5n25sdcv4YE=
16+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.11/go.mod h1:7bUb2sSr2MZ3M/N+VyETLTQtInemHXb/Fl3s8CLzm0Y=
1717
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 h1:VaRN3TlFdd6KxX1x3ILT5ynH6HvKgqdiXoTxAF4HQcQ=
1818
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1/go.mod h1:FbtygfRFze9usAadmnGJNc8KsP346kEe+y2/oyhGAGc=
1919
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.27 h1:AmB5QxnD+fBFrg9LcqzkgF/CaYvMyU/BTlejG4t1S7Q=
@@ -64,6 +64,8 @@ github.com/aws/aws-sdk-go-v2/service/s3 v1.72.3 h1:WZOmJfCDV+4tYacLxpiojoAdT5sxT
6464
github.com/aws/aws-sdk-go-v2/service/s3 v1.72.3/go.mod h1:xMekrnhmJ5aqmyxtmALs7mlvXw5xRh+eYjOjvrIIFJ4=
6565
github.com/aws/aws-sdk-go-v2/service/s3control v1.52.7 h1:cewH1fJ35N26pujUo8pXtqngf0QZio0ko62rT1x2Uak=
6666
github.com/aws/aws-sdk-go-v2/service/s3control v1.52.7/go.mod h1:zZ6ah0Hp8TqLZERFcwSQ2T5A4lMkX5vujkDvSkFiXh8=
67+
github.com/aws/aws-sdk-go-v2/service/s3vectors v1.4.10 h1:hgJrhznAL6SjFZAqNIexiE9L7Zjc5PMGmwPWNtTE3zc=
68+
github.com/aws/aws-sdk-go-v2/service/s3vectors v1.4.10/go.mod h1:gJNoydxeaa5Av62mqcKTcA/9oFJnnZRseWfDmPKfGv8=
6769
github.com/aws/aws-sdk-go-v2/service/shield v1.34.6 h1:AWKt4pVqiqzLIT3xoOThd0xT6dY1lSB+7yDcn0N3I48=
6870
github.com/aws/aws-sdk-go-v2/service/shield v1.34.6/go.mod h1:Io5NYTndCqsmL+vdfoQEkInZkbZn8gLloqEjGvng+7M=
6971
github.com/aws/aws-sdk-go-v2/service/ssmquicksetup v1.3.10 h1:3e9ZvkZB5NsDellLxPuaCJSeA5Hg7SeHY+Godotzizc=

mkdocs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,9 @@ nav:
580580
- S3 Bucket: resources/s3-bucket.md
581581
- S3 Multipart Upload: resources/s3-multipart-upload.md
582582
- S3 Object: resources/s3-object.md
583+
- S3 Vectors Bucket: resources/s3-vectors-bucket.md
584+
- S3 Vectors Index: resources/s3-vectors-index.md
585+
- S3 Vectors Vector: resources/s3-vectors-vector.md
583586
- SNS Endpoint: resources/sns-endpoint.md
584587
- SNS Platform Application: resources/sns-platform-application.md
585588
- SNS Subscription: resources/sns-subscription.md

resources/s3vectors-bucket.go

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package resources
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
"github.com/aws/aws-sdk-go-v2/service/s3vectors"
8+
9+
"github.com/ekristen/libnuke/pkg/registry"
10+
"github.com/ekristen/libnuke/pkg/resource"
11+
"github.com/ekristen/libnuke/pkg/types"
12+
13+
"github.com/ekristen/aws-nuke/v3/pkg/nuke"
14+
)
15+
16+
const S3VectorsBucketResource = "S3VectorsBucket"
17+
18+
func init() {
19+
registry.Register(&registry.Registration{
20+
Name: S3VectorsBucketResource,
21+
Scope: nuke.Account,
22+
Resource: &S3VectorsBucket{},
23+
Lister: &S3VectorsBucketLister{},
24+
DependsOn: []string{
25+
S3VectorsIndexResource,
26+
},
27+
})
28+
}
29+
30+
type S3VectorsBucketLister struct{}
31+
32+
func (l *S3VectorsBucketLister) List(ctx context.Context, o interface{}) ([]resource.Resource, error) {
33+
opts := o.(*nuke.ListerOpts)
34+
svc := s3vectors.NewFromConfig(*opts.Config)
35+
36+
var resources []resource.Resource
37+
params := &s3vectors.ListVectorBucketsInput{}
38+
39+
paginator := s3vectors.NewListVectorBucketsPaginator(svc, params)
40+
for paginator.HasMorePages() {
41+
page, err := paginator.NextPage(ctx)
42+
if err != nil {
43+
return nil, err
44+
}
45+
46+
for _, bucket := range page.VectorBuckets {
47+
resources = append(resources, &S3VectorsBucket{
48+
svc: svc,
49+
Name: bucket.VectorBucketName,
50+
ARN: bucket.VectorBucketArn,
51+
})
52+
}
53+
}
54+
55+
return resources, nil
56+
}
57+
58+
type S3VectorsBucket struct {
59+
svc *s3vectors.Client
60+
Name *string
61+
ARN *string
62+
}
63+
64+
func (r *S3VectorsBucket) Remove(ctx context.Context) error {
65+
_, err := r.svc.DeleteVectorBucket(ctx, &s3vectors.DeleteVectorBucketInput{
66+
VectorBucketName: r.Name,
67+
})
68+
return err
69+
}
70+
71+
func (r *S3VectorsBucket) Properties() types.Properties {
72+
return types.NewPropertiesFromStruct(r)
73+
}
74+
75+
func (r *S3VectorsBucket) String() string {
76+
return fmt.Sprintf("s3vectors://%s", *r.Name)
77+
}

resources/s3vectors-bucket_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package resources
2+
3+
import (
4+
"testing"
5+
6+
"github.com/gotidy/ptr"
7+
"github.com/stretchr/testify/assert"
8+
)
9+
10+
func Test_S3VectorsBucket_Properties(t *testing.T) {
11+
bucket := &S3VectorsBucket{
12+
Name: ptr.String("my-vector-bucket"),
13+
ARN: ptr.String("arn:aws:s3vectors:us-east-1:123456789012:bucket/my-vector-bucket"),
14+
}
15+
16+
properties := bucket.Properties()
17+
18+
assert.Equal(t, "my-vector-bucket", properties.Get("Name"))
19+
assert.Equal(t, "arn:aws:s3vectors:us-east-1:123456789012:bucket/my-vector-bucket", properties.Get("ARN"))
20+
}
21+
22+
func Test_S3VectorsBucket_String(t *testing.T) {
23+
bucket := &S3VectorsBucket{
24+
Name: ptr.String("test-vector-bucket"),
25+
}
26+
27+
assert.Equal(t, "s3vectors://test-vector-bucket", bucket.String())
28+
}

resources/s3vectors-index.go

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
package resources
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
"github.com/aws/aws-sdk-go-v2/service/s3vectors"
8+
9+
"github.com/ekristen/libnuke/pkg/registry"
10+
"github.com/ekristen/libnuke/pkg/resource"
11+
"github.com/ekristen/libnuke/pkg/types"
12+
13+
"github.com/ekristen/aws-nuke/v3/pkg/nuke"
14+
)
15+
16+
const S3VectorsIndexResource = "S3VectorsIndex"
17+
18+
func init() {
19+
registry.Register(&registry.Registration{
20+
Name: S3VectorsIndexResource,
21+
Scope: nuke.Account,
22+
Resource: &S3VectorsIndex{},
23+
Lister: &S3VectorsIndexLister{},
24+
DependsOn: []string{
25+
S3VectorsVectorResource,
26+
},
27+
})
28+
}
29+
30+
type S3VectorsIndexLister struct{}
31+
32+
func (l *S3VectorsIndexLister) List(ctx context.Context, o interface{}) ([]resource.Resource, error) {
33+
opts := o.(*nuke.ListerOpts)
34+
svc := s3vectors.NewFromConfig(*opts.Config)
35+
36+
var resources []resource.Resource
37+
38+
// First, list all vector buckets
39+
bucketsParams := &s3vectors.ListVectorBucketsInput{}
40+
bucketsPaginator := s3vectors.NewListVectorBucketsPaginator(svc, bucketsParams)
41+
42+
for bucketsPaginator.HasMorePages() {
43+
bucketsPage, err := bucketsPaginator.NextPage(ctx)
44+
if err != nil {
45+
return nil, err
46+
}
47+
48+
// For each bucket, list all indexes
49+
for _, bucket := range bucketsPage.VectorBuckets {
50+
indexParams := &s3vectors.ListIndexesInput{
51+
VectorBucketName: bucket.VectorBucketName,
52+
}
53+
54+
paginator := s3vectors.NewListIndexesPaginator(svc, indexParams)
55+
for paginator.HasMorePages() {
56+
page, err := paginator.NextPage(ctx)
57+
if err != nil {
58+
return nil, err
59+
}
60+
61+
for _, index := range page.Indexes {
62+
resources = append(resources, &S3VectorsIndex{
63+
svc: svc,
64+
BucketName: bucket.VectorBucketName,
65+
IndexName: index.IndexName,
66+
IndexARN: index.IndexArn,
67+
})
68+
}
69+
}
70+
}
71+
}
72+
73+
return resources, nil
74+
}
75+
76+
type S3VectorsIndex struct {
77+
svc *s3vectors.Client
78+
BucketName *string
79+
IndexName *string
80+
IndexARN *string
81+
}
82+
83+
func (r *S3VectorsIndex) Remove(ctx context.Context) error {
84+
_, err := r.svc.DeleteIndex(ctx, &s3vectors.DeleteIndexInput{
85+
VectorBucketName: r.BucketName,
86+
IndexName: r.IndexName,
87+
})
88+
return err
89+
}
90+
91+
func (r *S3VectorsIndex) Properties() types.Properties {
92+
return types.NewPropertiesFromStruct(r)
93+
}
94+
95+
func (r *S3VectorsIndex) String() string {
96+
return fmt.Sprintf("s3vectors://%s/%s", *r.BucketName, *r.IndexName)
97+
}

0 commit comments

Comments
 (0)