Skip to content

Commit 5be467a

Browse files
authored
Switch to S3 HEAD to find bucket location (#580)
1 parent 5e1c112 commit 5be467a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

s3/replica_client.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,12 @@ func (c *ReplicaClient) findBucketRegion(ctx context.Context, bucket string) (st
136136

137137
// Fetch bucket location, if possible. Must be bucket owner.
138138
// This call can return a nil location which means it's in us-east-1.
139-
if out, err := s3.New(sess).GetBucketLocation(&s3.GetBucketLocationInput{
139+
if out, err := s3.New(sess).HeadBucketWithContext(ctx, &s3.HeadBucketInput{
140140
Bucket: aws.String(bucket),
141141
}); err != nil {
142142
return "", err
143-
} else if out.LocationConstraint != nil {
144-
return *out.LocationConstraint, nil
143+
} else if out.BucketRegion != nil {
144+
return *out.BucketRegion, nil
145145
}
146146
return DefaultRegion, nil
147147
}

0 commit comments

Comments
 (0)