From 5be467a478adcffc5b3999b9503cc676c2bf09f1 Mon Sep 17 00:00:00 2001 From: Ananth Date: Sat, 20 Apr 2024 20:38:50 +0530 Subject: [PATCH] Switch to S3 HEAD to find bucket location (#580) --- s3/replica_client.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/s3/replica_client.go b/s3/replica_client.go index e03b428..7b51375 100644 --- a/s3/replica_client.go +++ b/s3/replica_client.go @@ -136,12 +136,12 @@ func (c *ReplicaClient) findBucketRegion(ctx context.Context, bucket string) (st // Fetch bucket location, if possible. Must be bucket owner. // 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), }); err != nil { return "", err - } else if out.LocationConstraint != nil { - return *out.LocationConstraint, nil + } else if out.BucketRegion != nil { + return *out.BucketRegion, nil } return DefaultRegion, nil }