Skip to content

Commit

Permalink
Merge pull request #2412 from IBM/issue-2411
Browse files Browse the repository at this point in the history
Vanity URLs with AWS result in bucket NOT_FOUND on  #2411
  • Loading branch information
prb112 committed May 27, 2021
2 parents 36e1874 + f1e9084 commit 95123b0
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public S3Provider(String source) throws FHIRException {

String cosLocation = adapter.getStorageProviderLocation(source);
String cosEndpointUrl = adapter.getStorageProviderEndpointInternal(source);
String bucketName = adapter.getStorageProviderBucketName(source);
bucketName = adapter.getStorageProviderBucketName(source);

boolean iam = adapter.isStorageProviderAuthTypeIam(source);
isExportPublic = adapter.isStorageProviderExportPublic(source);
Expand Down Expand Up @@ -169,12 +169,19 @@ private static AmazonS3 getClient(boolean iam, String cosApiKeyProperty, String
* checks to see if the bucket exists.
*
* @return
* @implNote to maintain the exists method behavior, we're only checking the client exists or does not (true or false), and warning if the bucket is not found as the S3 client does not do an exists properly when using a doesBucketExistV2 when using a vanity url to access the service on AWS.
*/
public boolean exists() {
boolean ex = client != null && client.doesBucketExistV2(bucketName);
if (ex == false) {
boolean ex = client != null;

// We only want to log a warning here, and assume it's true if the client exists.
// In certain circumstances, a direct url to the bucket can be used. https://mybucketdemo123.s3.us.east-2.amazonaws.com
// versus an API enabled url e.g. https://s3.us.east-2.amazonaws.com
// These end up with TWO different responses, the former is false, and the latter is true.
if (!ex || !client.doesBucketExistV2(bucketName)) {
logger.warning("Bucket '" + bucketName + "' not found! Client [" + (client != null) + "]");
}

return ex;
}

Expand Down

0 comments on commit 95123b0

Please sign in to comment.