Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions docs/resources/s3-vectors-bucket.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
generated: true
---

# S3VectorsBucket


## Resource

```text
S3VectorsBucket
```

## Properties


- `ARN`: No Description
- `Name`: No Description

!!! note - Using Properties
Properties are what [Filters](../config-filtering.md) are written against in your configuration. You use the property
names to write filters for what you want to **keep** and omit from the nuke process.

### String Property

The string representation of a resource is generally the value of the Name, ID or ARN field of the resource. Not all
resources support properties. To write a filter against the string representation, simply omit the `property` field in
the filter.

The string value is always what is used in the output of the log format when a resource is identified.

### DependsOn

!!! important - Experimental Feature
This resource depends on a resource using the experimental feature. This means that the resource will
only be deleted if all the resources of a particular type are deleted first or reach a terminal state.

- [S3VectorsIndex](./s3-vectors-index.md)
39 changes: 39 additions & 0 deletions docs/resources/s3-vectors-index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
generated: true
---

# S3VectorsIndex


## Resource

```text
S3VectorsIndex
```

## Properties


- `BucketName`: No Description
- `IndexARN`: No Description
- `IndexName`: No Description

!!! note - Using Properties
Properties are what [Filters](../config-filtering.md) are written against in your configuration. You use the property
names to write filters for what you want to **keep** and omit from the nuke process.

### String Property

The string representation of a resource is generally the value of the Name, ID or ARN field of the resource. Not all
resources support properties. To write a filter against the string representation, simply omit the `property` field in
the filter.

The string value is always what is used in the output of the log format when a resource is identified.

### DependsOn

!!! important - Experimental Feature
This resource depends on a resource using the experimental feature. This means that the resource will
only be deleted if all the resources of a particular type are deleted first or reach a terminal state.

- [S3VectorsVector](./s3-vectors-vector.md)
31 changes: 31 additions & 0 deletions docs/resources/s3-vectors-vector.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
generated: true
---

# S3VectorsVector


## Resource

```text
S3VectorsVector
```

## Properties


- `IndexName`: No Description
- `Key`: No Description
- `VectorBucketName`: No Description

!!! note - Using Properties
Properties are what [Filters](../config-filtering.md) are written against in your configuration. You use the property
names to write filters for what you want to **keep** and omit from the nuke process.

### String Property

The string representation of a resource is generally the value of the Name, ID or ARN field of the resource. Not all
resources support properties. To write a filter against the string representation, simply omit the `property` field in
the filter.

The string value is always what is used in the output of the log format when a resource is identified.
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ toolchain go1.25.3

require (
github.com/aws/aws-sdk-go v1.55.8
github.com/aws/aws-sdk-go-v2 v1.39.3
github.com/aws/aws-sdk-go-v2 v1.39.4
github.com/aws/aws-sdk-go-v2/config v1.28.11
github.com/aws/aws-sdk-go-v2/credentials v1.17.71
github.com/aws/aws-sdk-go-v2/service/amp v1.36.0
Expand All @@ -28,6 +28,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/route53profiles v1.4.17
github.com/aws/aws-sdk-go-v2/service/s3 v1.72.3
github.com/aws/aws-sdk-go-v2/service/s3control v1.52.7
github.com/aws/aws-sdk-go-v2/service/s3vectors v1.4.10
github.com/aws/aws-sdk-go-v2/service/shield v1.34.6
github.com/aws/aws-sdk-go-v2/service/ssmquicksetup v1.3.10
github.com/aws/aws-sdk-go-v2/service/sts v1.34.1
Expand All @@ -51,8 +52,8 @@ require (
require (
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.33 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.10 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.10 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.11 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.11 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.27 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.0 // indirect
Expand Down
14 changes: 8 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/aws/aws-sdk-go v1.55.8 h1:JRmEUbU52aJQZ2AjX4q4Wu7t4uZjOu71uyNmaWlUkJQ=
github.com/aws/aws-sdk-go v1.55.8/go.mod h1:ZkViS9AqA6otK+JBBNH2++sx1sgxrPKcSzPPvQkUtXk=
github.com/aws/aws-sdk-go-v2 v1.39.3 h1:h7xSsanJ4EQJXG5iuW4UqgP7qBopLpj84mpkNx3wPjM=
github.com/aws/aws-sdk-go-v2 v1.39.3/go.mod h1:yWSxrnioGUZ4WVv9TgMrNUeLV3PFESn/v+6T/Su8gnM=
github.com/aws/aws-sdk-go-v2 v1.39.4 h1:qTsQKcdQPHnfGYBBs+Btl8QwxJeoWcOcPcixK90mRhg=
github.com/aws/aws-sdk-go-v2 v1.39.4/go.mod h1:yWSxrnioGUZ4WVv9TgMrNUeLV3PFESn/v+6T/Su8gnM=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7 h1:lL7IfaFzngfx0ZwUGOZdsFFnQ5uLvR0hWqqhyE7Q9M8=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7/go.mod h1:QraP0UcVlQJsmHfioCrveWOC1nbiWUl3ej08h4mXWoc=
github.com/aws/aws-sdk-go-v2/config v1.28.11 h1:7Ekru0IkRHRnSRWGQLnLN6i0o1Jncd0rHo2T130+tEQ=
Expand All @@ -10,10 +10,10 @@ github.com/aws/aws-sdk-go-v2/credentials v1.17.71 h1:r2w4mQWnrTMJjOyIsZtGp3R3XGY
github.com/aws/aws-sdk-go-v2/credentials v1.17.71/go.mod h1:E7VF3acIup4GB5ckzbKFrCK0vTvEQxOxgdq4U3vcMCY=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.33 h1:D9ixiWSG4lyUBL2DDNK924Px9V/NBVpML90MHqyTADY=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.33/go.mod h1:caS/m4DI+cij2paz3rtProRBI4s/+TCiWoaWZuQ9010=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.10 h1:mj/bdWleWEh81DtpdHKkw41IrS+r3uw1J/VQtbwYYp8=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.10/go.mod h1:7+oEMxAZWP8gZCyjcm9VicI0M61Sx4DJtcGfKYv2yKQ=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.10 h1:wh+/mn57yhUrFtLIxyFPh2RgxgQz/u+Yrf7hiHGHqKY=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.10/go.mod h1:7zirD+ryp5gitJJ2m1BBux56ai8RIRDykXZrJSp540w=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.11 h1:7AANQZkF3ihM8fbdftpjhken0TP9sBzFbV/Ze/Y4HXA=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.11/go.mod h1:NTF4QCGkm6fzVwncpkFQqoquQyOolcyXfbpC98urj+c=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.11 h1:ShdtWUZT37LCAA4Mw2kJAJtzaszfSHFb5n25sdcv4YE=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.11/go.mod h1:7bUb2sSr2MZ3M/N+VyETLTQtInemHXb/Fl3s8CLzm0Y=
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 h1:VaRN3TlFdd6KxX1x3ILT5ynH6HvKgqdiXoTxAF4HQcQ=
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1/go.mod h1:FbtygfRFze9usAadmnGJNc8KsP346kEe+y2/oyhGAGc=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.27 h1:AmB5QxnD+fBFrg9LcqzkgF/CaYvMyU/BTlejG4t1S7Q=
Expand Down Expand Up @@ -64,6 +64,8 @@ github.com/aws/aws-sdk-go-v2/service/s3 v1.72.3 h1:WZOmJfCDV+4tYacLxpiojoAdT5sxT
github.com/aws/aws-sdk-go-v2/service/s3 v1.72.3/go.mod h1:xMekrnhmJ5aqmyxtmALs7mlvXw5xRh+eYjOjvrIIFJ4=
github.com/aws/aws-sdk-go-v2/service/s3control v1.52.7 h1:cewH1fJ35N26pujUo8pXtqngf0QZio0ko62rT1x2Uak=
github.com/aws/aws-sdk-go-v2/service/s3control v1.52.7/go.mod h1:zZ6ah0Hp8TqLZERFcwSQ2T5A4lMkX5vujkDvSkFiXh8=
github.com/aws/aws-sdk-go-v2/service/s3vectors v1.4.10 h1:hgJrhznAL6SjFZAqNIexiE9L7Zjc5PMGmwPWNtTE3zc=
github.com/aws/aws-sdk-go-v2/service/s3vectors v1.4.10/go.mod h1:gJNoydxeaa5Av62mqcKTcA/9oFJnnZRseWfDmPKfGv8=
github.com/aws/aws-sdk-go-v2/service/shield v1.34.6 h1:AWKt4pVqiqzLIT3xoOThd0xT6dY1lSB+7yDcn0N3I48=
github.com/aws/aws-sdk-go-v2/service/shield v1.34.6/go.mod h1:Io5NYTndCqsmL+vdfoQEkInZkbZn8gLloqEjGvng+7M=
github.com/aws/aws-sdk-go-v2/service/ssmquicksetup v1.3.10 h1:3e9ZvkZB5NsDellLxPuaCJSeA5Hg7SeHY+Godotzizc=
Expand Down
3 changes: 3 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,9 @@ nav:
- S3 Bucket: resources/s3-bucket.md
- S3 Multipart Upload: resources/s3-multipart-upload.md
- S3 Object: resources/s3-object.md
- S3 Vectors Bucket: resources/s3-vectors-bucket.md
- S3 Vectors Index: resources/s3-vectors-index.md
- S3 Vectors Vector: resources/s3-vectors-vector.md
- SNS Endpoint: resources/sns-endpoint.md
- SNS Platform Application: resources/sns-platform-application.md
- SNS Subscription: resources/sns-subscription.md
Expand Down
76 changes: 76 additions & 0 deletions resources/s3vectors-bucket.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package resources

import (
"context"

"github.com/aws/aws-sdk-go-v2/service/s3vectors"

"github.com/ekristen/libnuke/pkg/registry"
"github.com/ekristen/libnuke/pkg/resource"
"github.com/ekristen/libnuke/pkg/types"

"github.com/ekristen/aws-nuke/v3/pkg/nuke"
)

const S3VectorsBucketResource = "S3VectorsBucket"

func init() {
registry.Register(&registry.Registration{
Name: S3VectorsBucketResource,
Scope: nuke.Account,
Resource: &S3VectorsBucket{},
Lister: &S3VectorsBucketLister{},
DependsOn: []string{
S3VectorsIndexResource,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the hierarchy implemented:
S3VectorsBucket depends on S3VectorsIndex, which depends on S3VectorsVector.

Is it possible for an S3VectorsVector to exist without an S3VectorsIndex?
If so, the Bucket should also depend on it.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will also say that the dependency hierarchy is definitely experimental and a bit buggy, it can cause some stalled removes. Love that you are using it, or might be, would appreciate any feedback to issues you encounter.

},
})
}

type S3VectorsBucketLister struct{}

func (l *S3VectorsBucketLister) List(ctx context.Context, o interface{}) ([]resource.Resource, error) {
opts := o.(*nuke.ListerOpts)
svc := s3vectors.NewFromConfig(*opts.Config)

var resources []resource.Resource
params := &s3vectors.ListVectorBucketsInput{}

paginator := s3vectors.NewListVectorBucketsPaginator(svc, params)
for paginator.HasMorePages() {
page, err := paginator.NextPage(ctx)
if err != nil {
return nil, err
}

for _, bucket := range page.VectorBuckets {
resources = append(resources, &S3VectorsBucket{
svc: svc,
Name: bucket.VectorBucketName,
ARN: bucket.VectorBucketArn,
})
}
}

return resources, nil
}

type S3VectorsBucket struct {
svc *s3vectors.Client
Name *string
ARN *string
}

func (r *S3VectorsBucket) Remove(ctx context.Context) error {
_, err := r.svc.DeleteVectorBucket(ctx, &s3vectors.DeleteVectorBucketInput{
VectorBucketName: r.Name,
})
return err
}

func (r *S3VectorsBucket) Properties() types.Properties {
return types.NewPropertiesFromStruct(r)
}

func (r *S3VectorsBucket) String() string {
return *r.Name
}
28 changes: 28 additions & 0 deletions resources/s3vectors-bucket_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package resources

import (
"testing"

"github.com/gotidy/ptr"
"github.com/stretchr/testify/assert"
)

func Test_S3VectorsBucket_Properties(t *testing.T) {
bucket := &S3VectorsBucket{
Name: ptr.String("my-vector-bucket"),
ARN: ptr.String("arn:aws:s3vectors:us-east-1:123456789012:bucket/my-vector-bucket"),
}

properties := bucket.Properties()

assert.Equal(t, "my-vector-bucket", properties.Get("Name"))
assert.Equal(t, "arn:aws:s3vectors:us-east-1:123456789012:bucket/my-vector-bucket", properties.Get("ARN"))
}

func Test_S3VectorsBucket_String(t *testing.T) {
bucket := &S3VectorsBucket{
Name: ptr.String("test-vector-bucket"),
}

assert.Equal(t, "test-vector-bucket", bucket.String())
}
96 changes: 96 additions & 0 deletions resources/s3vectors-index.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package resources

import (
"context"

"github.com/aws/aws-sdk-go-v2/service/s3vectors"

"github.com/ekristen/libnuke/pkg/registry"
"github.com/ekristen/libnuke/pkg/resource"
"github.com/ekristen/libnuke/pkg/types"

"github.com/ekristen/aws-nuke/v3/pkg/nuke"
)

const S3VectorsIndexResource = "S3VectorsIndex"

func init() {
registry.Register(&registry.Registration{
Name: S3VectorsIndexResource,
Scope: nuke.Account,
Resource: &S3VectorsIndex{},
Lister: &S3VectorsIndexLister{},
DependsOn: []string{
S3VectorsVectorResource,
},
})
}

type S3VectorsIndexLister struct{}

func (l *S3VectorsIndexLister) List(ctx context.Context, o interface{}) ([]resource.Resource, error) {
opts := o.(*nuke.ListerOpts)
svc := s3vectors.NewFromConfig(*opts.Config)

var resources []resource.Resource

// First, list all vector buckets
bucketsParams := &s3vectors.ListVectorBucketsInput{}
bucketsPaginator := s3vectors.NewListVectorBucketsPaginator(svc, bucketsParams)

for bucketsPaginator.HasMorePages() {
bucketsPage, err := bucketsPaginator.NextPage(ctx)
if err != nil {
return nil, err
}

// For each bucket, list all indexes
for _, bucket := range bucketsPage.VectorBuckets {
indexParams := &s3vectors.ListIndexesInput{
VectorBucketName: bucket.VectorBucketName,
}

paginator := s3vectors.NewListIndexesPaginator(svc, indexParams)
for paginator.HasMorePages() {
page, err := paginator.NextPage(ctx)
if err != nil {
return nil, err
}

for _, index := range page.Indexes {
resources = append(resources, &S3VectorsIndex{
svc: svc,
BucketName: bucket.VectorBucketName,
IndexName: index.IndexName,
IndexARN: index.IndexArn,
})
}
}
}
}

return resources, nil
}

type S3VectorsIndex struct {
svc *s3vectors.Client
BucketName *string
IndexName *string
IndexARN *string
}

func (r *S3VectorsIndex) Remove(ctx context.Context) error {
_, err := r.svc.DeleteIndex(ctx, &s3vectors.DeleteIndexInput{
VectorBucketName: r.BucketName,
IndexName: r.IndexName,
})
return err
}

func (r *S3VectorsIndex) Properties() types.Properties {
return types.NewPropertiesFromStruct(r)
}

func (r *S3VectorsIndex) String() string {
return *r.IndexName
}
Loading
Loading