Switch to S3 HEAD to find bucket location (#580)

This commit is contained in:
Ananth
2024-04-20 20:38:50 +05:30
committed by GitHub
parent 5e1c112468
commit 5be467a478

View File

@@ -136,12 +136,12 @@ func (c *ReplicaClient) findBucketRegion(ctx context.Context, bucket string) (st
// Fetch bucket location, if possible. Must be bucket owner. // Fetch bucket location, if possible. Must be bucket owner.
// This call can return a nil location which means it's in us-east-1. // This call can return a nil location which means it's in us-east-1.
if out, err := s3.New(sess).GetBucketLocation(&s3.GetBucketLocationInput{ if out, err := s3.New(sess).HeadBucketWithContext(ctx, &s3.HeadBucketInput{
Bucket: aws.String(bucket), Bucket: aws.String(bucket),
}); err != nil { }); err != nil {
return "", err return "", err
} else if out.LocationConstraint != nil { } else if out.BucketRegion != nil {
return *out.LocationConstraint, nil return *out.BucketRegion, nil
} }
return DefaultRegion, nil return DefaultRegion, nil
} }