From 27b2c8db334652f969ce69a89d931ad39b99fbca Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Thu, 30 Nov 2023 11:46:37 -0500 Subject: [PATCH] r/aws_s3_directory_bucket: Fix sweeper. --- internal/service/s3/sweep.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/internal/service/s3/sweep.go b/internal/service/s3/sweep.go index a86164dfc42..b8fabe22809 100644 --- a/internal/service/s3/sweep.go +++ b/internal/service/s3/sweep.go @@ -114,7 +114,7 @@ func sweepObjects(region string) error { continue } - sweepables = append(sweepables, objectSweeper{ + sweepables = append(sweepables, directoryBucketObjectSweeper{ conn: conn, bucket: aws.ToString(v.Name), }) @@ -145,6 +145,19 @@ func (os objectSweeper) Delete(ctx context.Context, timeout time.Duration, optFn return nil } +type directoryBucketObjectSweeper struct { + conn *s3.Client + bucket string +} + +func (os directoryBucketObjectSweeper) Delete(ctx context.Context, timeout time.Duration, optFns ...tfresource.OptionsFunc) error { + _, err := emptyDirectoryBucket(ctx, os.conn, os.bucket) + if err != nil { + return fmt.Errorf("deleting S3 Directory Bucket (%s) objects: %w", os.bucket, err) + } + return nil +} + func sweepBuckets(region string) error { ctx := sweep.Context(region) client, err := sweep.SharedRegionalSweepClient(ctx, region)