Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

Commit

Permalink
fix: Possible use of a wrong region in s3 buckets. (#1052)
Browse files Browse the repository at this point in the history
  • Loading branch information
irmatov authored Jun 14, 2022
1 parent a48cf77 commit e54b46a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions resources/services/s3/buckets.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,12 +510,18 @@ func fetchS3Buckets(ctx context.Context, meta schema.ClientMeta, _ *schema.Resou

func fetchS3BucketsWorker(ctx context.Context, meta schema.ClientMeta, buckets <-chan types.Bucket, errs chan<- error, res chan<- interface{}, wg *sync.WaitGroup) {
defer wg.Done()
cl := meta.(*client.Client)
for bucket := range buckets {
// always set default bucket region to us-east-1
wb := &WrappedBucket{Bucket: bucket, Region: "us-east-1"}
e := resolveS3BucketsAttributes(ctx, meta, wb)
err := resolveS3BucketsAttributes(ctx, meta, wb)
if err != nil {
if !cl.IsNotFoundError(err) {
errs <- err
}
continue
}
res <- wb
errs <- e
}
}

Expand All @@ -527,9 +533,6 @@ func resolveS3BucketsAttributes(ctx context.Context, meta schema.ClientMeta, res

output, err := mgr.GetBucketRegion(ctx, *resource.Name)
if err != nil {
if c.IsNotFoundError(err) {
return nil
}
return diag.WrapError(err)
}
// This is a weird corner case by AWS API https://github.com/aws/aws-sdk-net/issues/323#issuecomment-196584538
Expand Down

0 comments on commit e54b46a

Please sign in to comment.