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 - connector check ignores the s3_bucket_path #15207

Merged
merged 23 commits into from
Aug 24, 2022
Merged
Changes from 9 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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 @@ -59,7 +59,7 @@ public AirbyteConnectionStatus check(final JsonNode config) {
final S3StorageOperations storageOperations = new S3StorageOperations(nameTransformer, s3Client, destinationConfig);

// Test for writing, list and delete
S3Destination.attemptS3WriteAndDelete(storageOperations, destinationConfig, destinationConfig.getBucketName());
S3Destination.attemptS3WriteAndDelete(storageOperations, destinationConfig, destinationConfig.getBucketPath());

// Test single upload (for small files) permissions
testSingleUpload(s3Client, destinationConfig.getBucketName(), destinationConfig.getBucketPath());
Expand Down Expand Up @@ -136,16 +136,17 @@ static void attemptS3WriteAndDelete(final S3StorageOperations storageOperations,
final AmazonS3 s3) {
final var prefix = bucketPath.isEmpty() ? "" : bucketPath + (bucketPath.endsWith("/") ? "" : "/");
final String outputTableName = prefix + "_airbyte_connection_test_" + UUID.randomUUID().toString().replaceAll("-", "");
attemptWriteAndDeleteS3Object(storageOperations, s3Config, outputTableName, s3);
attemptWriteAndDeleteS3Object(storageOperations, s3Config, outputTableName, s3, bucketPath);
}

private static void attemptWriteAndDeleteS3Object(final S3StorageOperations storageOperations,
final S3DestinationConfig s3Config,
final String outputTableName,
final AmazonS3 s3) {
final AmazonS3 s3,
final String bucketPath) {
final var s3Bucket = s3Config.getBucketName();

storageOperations.createBucketObjectIfNotExists(s3Bucket);
storageOperations.createBucketObjectIfNotExists(bucketPath);
s3.putObject(s3Bucket, outputTableName, "check-content");
testIAMUserHasListObjectPermission(s3, s3Bucket);
s3.deleteObject(s3Bucket, outputTableName);
Expand Down