Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vanity URLs with AWS result in bucket NOT_FOUND on #2411 #2412

Merged
merged 5 commits into from
May 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
prb112 marked this conversation as resolved.
Show resolved Hide resolved
* @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() {
prb112 marked this conversation as resolved.
Show resolved Hide resolved
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