Skip to content

Commit

Permalink
ARSN-26 interrogate the default region for getBucketLocation
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas2bert committed Oct 19, 2021
1 parent bfbda5d commit ab3fa2f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/storage/data/external/AwsClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class AwsClient {
}

setup(cb) {
// NOTE: to get the bucket location we interrogate the default
// region (us-east-1) and not the bucket's region (ref: ARTESCA-2141)
this._client.config.update({ region: 'us-east-1' });
// this request implicitly updates the endpoint for the location
// the following code explcitly sets it to avoid surprises
this._client.getBucketLocation({ Bucket: this._awsBucketName },
Expand All @@ -48,6 +51,8 @@ class AwsClient {
} else if (res) {
region = res.LocationConstraint;
}
this._client.config.update({ region });

const isAWS = this._s3Params.endpoint.endsWith('amazonaws.com');
if (region && isAWS) {
const endpoint = `s3.${region}.amazonaws.com`;
Expand Down

0 comments on commit ab3fa2f

Please sign in to comment.