xiaoxuandev commented on a change in pull request #4280:
URL: https://github.com/apache/iceberg/pull/4280#discussion_r830696372



##########
File path: 
aws/src/main/java/org/apache/iceberg/aws/LakeFormationAwsClientFactory.java
##########
@@ -0,0 +1,148 @@
+/*
+ * 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.net.URI;
+import java.util.Map;
+import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import software.amazon.awssdk.auth.credentials.AwsCredentials;
+import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
+import software.amazon.awssdk.auth.credentials.AwsSessionCredentials;
+import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
+import software.amazon.awssdk.regions.PartitionMetadata;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.glue.GlueClient;
+import software.amazon.awssdk.services.glue.model.GetTableRequest;
+import software.amazon.awssdk.services.glue.model.GetTableResponse;
+import software.amazon.awssdk.services.kms.KmsClient;
+import software.amazon.awssdk.services.kms.KmsClientBuilder;
+import software.amazon.awssdk.services.lakeformation.LakeFormationClient;
+import 
software.amazon.awssdk.services.lakeformation.model.GetTemporaryGlueTableCredentialsRequest;
+import 
software.amazon.awssdk.services.lakeformation.model.GetTemporaryGlueTableCredentialsResponse;
+import software.amazon.awssdk.services.lakeformation.model.Permission;
+import software.amazon.awssdk.services.s3.S3Client;
+import software.amazon.awssdk.services.s3.S3ClientBuilder;
+
+/**
+ * This implementation of AwsClientFactory is used if LakeFormation is enabled.
+ * It extends AssumeRoleAwsClientFactory to reuse the assuming-role approach 
for all clients except S3 and KMS.
+ * If a table is registered with LakeFormation, the S3/KMS client will use 
LakeFormation credentials,
+ * otherwise it uses AssumingRole credentials.
+ */
+public class LakeFormationAwsClientFactory extends AssumeRoleAwsClientFactory {
+  public static final String LF_AUTHORIZED_CALLER = 
"LakeFormationAuthorizedCaller";
+  private String glueCatalogId;
+  private String dbName;
+  private String tableName;
+  private String accountId;
+  private String region;
+
+  public LakeFormationAwsClientFactory() {
+  }
+
+  @Override
+  public void initialize(Map<String, String> catalogProperties) {
+    super.initialize(catalogProperties);
+    Preconditions.checkArgument(tags().stream().anyMatch(t -> 
t.key().equals(LF_AUTHORIZED_CALLER)),
+        "must set %s through %s", LF_AUTHORIZED_CALLER, 
AwsProperties.CLIENT_ASSUME_ROLE_TAGS_PREFIX);
+    this.glueCatalogId = catalogProperties.get(AwsProperties.GLUE_CATALOG_ID);
+    this.dbName = catalogProperties.get(AwsProperties.LAKE_FORMATION_DB_NAME);
+    this.tableName = 
catalogProperties.get(AwsProperties.LAKE_FORMATION_TABLE_NAME);
+    this.accountId = catalogProperties.get(AwsProperties.GLUE_ACCOUNT_ID);
+    this.region = 
catalogProperties.get(AwsProperties.CLIENT_ASSUME_ROLE_REGION);

Review comment:
       removed.  thanks!




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