Skip to content

Commit

Permalink
Switch to S3 HEAD to find bucket location (benbjohnson#580)
Browse files Browse the repository at this point in the history
  • Loading branch information
ananthb authored Apr 20, 2024
1 parent 5e1c112 commit 5be467a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions s3/replica_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 5be467a

Please sign in to comment.