From c2f936c5842829c69d0386d14ed8510aa6b8bcfd Mon Sep 17 00:00:00 2001 From: Erik Kristensen Date: Mon, 23 Dec 2024 12:14:05 -0700 Subject: [PATCH 1/3] fix(resource-explorer2-index): limit to current region --- resources/resource-explorer2-indexes.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/resources/resource-explorer2-indexes.go b/resources/resource-explorer2-indexes.go index d771d6d4..b0f9a2b1 100644 --- a/resources/resource-explorer2-indexes.go +++ b/resources/resource-explorer2-indexes.go @@ -33,7 +33,10 @@ func (l *ResourceExplorer2IndexLister) List(_ context.Context, o interface{}) ([ svc := resourceexplorer2.New(opts.Session) var resources []resource.Resource - params := &resourceexplorer2.ListIndexesInput{} + params := &resourceexplorer2.ListIndexesInput{ + Regions: aws.StringSlice([]string{opts.Region.Name}), + MaxResults: aws.Int64(100), + } for { output, err := svc.ListIndexes(params) From e457ef36f3db482f5cd070f18ad2f9456aeda2ea Mon Sep 17 00:00:00 2001 From: Erik Kristensen Date: Mon, 23 Dec 2024 12:15:04 -0700 Subject: [PATCH 2/3] refactor(resource-explorer2-index): standardization --- ...plorer2-indexes.go => resource-explorer2-index.go} | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) rename resources/{resource-explorer2-indexes.go => resource-explorer2-index.go} (86%) diff --git a/resources/resource-explorer2-indexes.go b/resources/resource-explorer2-index.go similarity index 86% rename from resources/resource-explorer2-indexes.go rename to resources/resource-explorer2-index.go index b0f9a2b1..03cb03e3 100644 --- a/resources/resource-explorer2-indexes.go +++ b/resources/resource-explorer2-index.go @@ -2,7 +2,6 @@ package resources import ( "context" - "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/resourceexplorer2" "github.com/ekristen/aws-nuke/v3/pkg/nuke" @@ -61,14 +60,14 @@ func (l *ResourceExplorer2IndexLister) List(_ context.Context, o interface{}) ([ return resources, nil } -func (f *ResourceExplorer2Index) Remove(_ context.Context) error { - _, err := f.svc.DeleteIndex(&resourceexplorer2.DeleteIndexInput{ - Arn: f.indexArn, +func (r *ResourceExplorer2Index) Remove(_ context.Context) error { + _, err := r.svc.DeleteIndex(&resourceexplorer2.DeleteIndexInput{ + Arn: r.indexArn, }) return err } -func (f *ResourceExplorer2Index) String() string { - return *f.indexArn +func (r *ResourceExplorer2Index) String() string { + return *r.indexArn } From aa8a6ffdec287f996b5a4dc7c12d1d3a24fb2865 Mon Sep 17 00:00:00 2001 From: Erik Kristensen Date: Mon, 23 Dec 2024 12:17:15 -0700 Subject: [PATCH 3/3] feat(resource-explorer2-index): add properties --- resources/resource-explorer2-index.go | 30 ++++++++++++++++++--------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/resources/resource-explorer2-index.go b/resources/resource-explorer2-index.go index 03cb03e3..06a5ea4c 100644 --- a/resources/resource-explorer2-index.go +++ b/resources/resource-explorer2-index.go @@ -2,11 +2,15 @@ package resources import ( "context" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/resourceexplorer2" - "github.com/ekristen/aws-nuke/v3/pkg/nuke" + "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 ResourceExplorer2IndexResource = "ResourceExplorer2Index" @@ -22,11 +26,6 @@ func init() { type ResourceExplorer2IndexLister struct{} -type ResourceExplorer2Index struct { - svc *resourceexplorer2.ResourceExplorer2 - indexArn *string -} - func (l *ResourceExplorer2IndexLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) { opts := o.(*nuke.ListerOpts) svc := resourceexplorer2.New(opts.Session) @@ -45,8 +44,9 @@ func (l *ResourceExplorer2IndexLister) List(_ context.Context, o interface{}) ([ for _, index := range output.Indexes { resources = append(resources, &ResourceExplorer2Index{ - svc: svc, - indexArn: index.Arn, + svc: svc, + ARN: index.Arn, + Type: index.Type, }) } @@ -60,14 +60,24 @@ func (l *ResourceExplorer2IndexLister) List(_ context.Context, o interface{}) ([ return resources, nil } +type ResourceExplorer2Index struct { + svc *resourceexplorer2.ResourceExplorer2 + ARN *string + Type *string +} + func (r *ResourceExplorer2Index) Remove(_ context.Context) error { _, err := r.svc.DeleteIndex(&resourceexplorer2.DeleteIndexInput{ - Arn: r.indexArn, + Arn: r.ARN, }) return err } func (r *ResourceExplorer2Index) String() string { - return *r.indexArn + return *r.ARN +} + +func (r *ResourceExplorer2Index) Properties() types.Properties { + return types.NewPropertiesFromStruct(r) }