dpaani commented on code in PR #7066:
URL: https://github.com/apache/iceberg/pull/7066#discussion_r1145474154


##########
aws/src/main/java/org/apache/iceberg/aws/AwsProperties.java:
##########
@@ -1061,18 +1103,30 @@ public Map<String, String> httpClientProperties() {
     return httpClientProperties;
   }
 
+  public String clientRegion() {
+    return clientRegion;
+  }
+
+  public void setClientRegion(String clientRegion) {
+    this.clientRegion = clientRegion;
+  }
+
   /**
    * Configure the credentials for an S3 client.
    *
    * <p>Sample usage:
    *
    * <pre>
-   *     
S3Client.builder().applyMutation(awsProperties::applyS3CredentialConfigurations)
+   *     
S3Client.builder().applyMutation(awsProperties::applyCredentialConfigurations)
    * </pre>
    */
-  public <T extends S3ClientBuilder> void applyS3CredentialConfigurations(T 
builder) {
-    builder.credentialsProvider(
-        credentialsProvider(s3AccessKeyId, s3SecretAccessKey, s3SessionToken));
+  public <T extends AwsClientBuilder> void applyCredentialConfigurations(T 
builder) {
+    if (!Strings.isNullOrEmpty(this.clientCredentialsProvider)) {
+      
builder.credentialsProvider(credentialsProvider(this.clientCredentialsProvider));
+    } else {
+      builder.credentialsProvider(

Review Comment:
   hi @jackye1995 .  Sorry, I am still not getting. This is how I have 
implemented.
   
   DefaultAwsClientFactory.s3() method calls applyS3CredentialConfigurations() 
method
   ```
   public S3Client s3() {
         return S3Client.builder()
             .applyMutation(awsProperties::applyClientRegionConfiguration)
             .applyMutation(awsProperties::applyHttpClientConfigurations)
             .applyMutation(awsProperties::applyS3EndpointConfigurations)
             .applyMutation(awsProperties::applyS3ServiceConfigurations)
             .applyMutation(awsProperties::applyS3CredentialConfigurations)
             .applyMutation(awsProperties::applyS3SignerConfiguration)
             .build();
       }
   ```
   
   then applyS3CredentialConfigurations method in AwsProperties calls 
credentialsProvider() method
   
   ```
   public <T extends AwsClientBuilder> void applyS3CredentialConfigurations(T 
builder) {
       builder.credentialsProvider(
           credentialsProvider(s3AccessKeyId, s3SecretAccessKey, 
s3SessionToken));
     }
   ```
   
   I have added this code to check credentialsProvider as fallback if s3 keys 
not set
   ```
     private AwsCredentialsProvider credentialsProvider(
         String accessKeyId, String secretAccessKey, String sessionToken) {
       if (accessKeyId != null) {
         if (sessionToken == null) {
           return StaticCredentialsProvider.create(
               AwsBasicCredentials.create(accessKeyId, secretAccessKey));
         } else {
           return StaticCredentialsProvider.create(
               AwsSessionCredentials.create(accessKeyId, secretAccessKey, 
sessionToken));
         }
       }
   
       if (!Strings.isNullOrEmpty(this.clientCredentialsProvider)) {
         return credentialsProvider(this.clientCredentialsProvider);
       }
   
       return DefaultCredentialsProvider.create();
     }
   ```
   This is only for S3. All other clients will use 
`.applyMutation(awsProperties::applyCredentialConfigurations)`
   ```
     public <T extends AwsClientBuilder> void applyCredentialConfigurations(T 
builder) {
       if (!Strings.isNullOrEmpty(this.clientCredentialsProvider)) {
         
builder.credentialsProvider(credentialsProvider(this.clientCredentialsProvider));
       }
     }
   ```
   
   
   
   



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to