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

Destination S3: check to verify prefix access instead of full-bucket access #4130

Merged
merged 1 commit into from
Jun 16, 2021
Merged
Show file tree
Hide file tree
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 @@ -201,13 +201,20 @@ private void closeAndWaitForUpload() throws IOException {
}

public static void attemptS3WriteAndDelete(S3Config s3Config) {
final String outputTableName = "_airbyte_connection_test_" + UUID.randomUUID().toString().replaceAll("-", "");
attemptS3WriteAndDelete(s3Config, "");
}

public static void attemptS3WriteAndDelete(S3Config s3Config, String bucketPath) {
var prefix = bucketPath.isEmpty() ? "":
bucketPath + (bucketPath.endsWith("/") ? "" : "/");
final String outputTableName = prefix + "_airbyte_connection_test_" + UUID.randomUUID().toString().replaceAll("-", "");
attemptWriteAndDeleteS3Object(s3Config, outputTableName);
}

private static void attemptWriteAndDeleteS3Object(S3Config s3Config, String outputTableName) {
var s3 = getAmazonS3(s3Config);
var s3Bucket = s3Config.getBucketName();

s3.putObject(s3Bucket, outputTableName, "check-content");
s3.deleteObject(s3Bucket, outputTableName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static void main(String[] args) throws Exception {
@Override
public AirbyteConnectionStatus check(JsonNode config) {
try {
S3StreamCopier.attemptS3WriteAndDelete(S3Config.getS3Config(config));
S3StreamCopier.attemptS3WriteAndDelete(S3Config.getS3Config(config), config.get("s3_bucket_path").asText());
return new AirbyteConnectionStatus().withStatus(Status.SUCCEEDED);
} catch (Exception e) {
LOGGER.error("Exception attempting to access the S3 bucket: ", e);
Expand Down