jackye1995 commented on a change in pull request #1844: URL: https://github.com/apache/iceberg/pull/1844#discussion_r533798912
########## File path: aws/src/main/java/org/apache/iceberg/aws/AwsClientCredentialsFactory.java ########## @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.iceberg.aws; + +import java.io.Serializable; +import org.apache.iceberg.catalog.CatalogConfigurable; +import software.amazon.awssdk.awscore.client.builder.AwsClientBuilder; + +/** + * Interface for loading a custom factory to configure AWS credentials for different services. + * See {@link AssumeRoleCredentialsFactory} as an example. Review comment: I see, yes I have been personally debating about this and that's why I put up this PR for feedbacks. We can either as you suggest provide integration points to load each AWS client, or in my current PR to provide integration points to load important aspects like credential providers, and there are pros and cons for both. Currently what I see is that we will at least have the following clients in the AWS module: - Glue - DynamoDB - S3 - KMS - (planned) CloudWatch - and might be more And in my use cases listed, it is much cleaner to just expose a holistic factory for credentials rather than to load every single AWS client dynamically. So what about exposing a single factory named `AwsClientConfigurationFactory`, for people to configure any client configuration? It will look like: ```java public interface AwsClientConfigurationFactory implements CatalogConfigurable, Serializable { <T extends AwsClientBuilder & AwsSyncClientBuilder> T configure(T clientBuilder); } public class MyClientConfigurationFactory implements AwsClientConfigurationFactory { <T extends AwsClientBuilder & AwsSyncClientBuilder> T configure(T clientBuilder) { if (clientBuilder instanceof S3ClientBuilder) { S3ClientBuilder s3Clientbuilder = (S3ClientBuilder) clientBuilder; // do whatever you want with s3 } // do common stuffs across all client builders clientBuilder.credentialsProvider(...); } } ``` By doing so, there is only 1 integration point for all AWS clients, and it can satisfy all both use case for configuring a single client, or configuring common properties across all clients. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
