-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[feat](catalog)AWS Glue supports S3 access via IAM AssumeRole. #56311
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
Changes from all commits
3b139ed
867f92b
e9583d1
a398e81
0866e0b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ | |
| import org.apache.doris.datasource.property.ConnectorProperty; | ||
|
|
||
| import com.amazonaws.ClientConfiguration; | ||
| import com.amazonaws.glue.catalog.util.AWSGlueConfig; | ||
| import org.apache.hadoop.hive.conf.HiveConf; | ||
|
|
||
| import java.util.Map; | ||
|
|
@@ -73,6 +74,7 @@ public class HMSGlueMetaStoreProperties extends AbstractHMSProperties { | |
| protected String awsGlueCatalogSeparator = ""; | ||
|
|
||
| // ========== Constructor ========== | ||
|
|
||
| /** | ||
| * Constructs an instance with the given metastore type and original properties. | ||
| * | ||
|
|
@@ -98,9 +100,6 @@ private void initHiveConf() { | |
| hiveConf = new HiveConf(); | ||
| hiveConf.set(AWS_GLUE_ENDPOINT_KEY, baseProperties.glueEndpoint); | ||
| hiveConf.set(AWS_REGION_KEY, baseProperties.glueRegion); | ||
| hiveConf.set(AWS_GLUE_SESSION_TOKEN_KEY, baseProperties.glueSessionToken); | ||
| hiveConf.set(AWS_GLUE_ACCESS_KEY_KEY, baseProperties.glueAccessKey); | ||
| hiveConf.set(AWS_GLUE_SECRET_KEY_KEY, baseProperties.glueSecretKey); | ||
| hiveConf.set(AWS_GLUE_MAX_RETRY_KEY, String.valueOf(awsGlueMaxErrorRetries)); | ||
| hiveConf.set(AWS_GLUE_MAX_CONNECTIONS_KEY, String.valueOf(awsGlueMaxConnections)); | ||
| hiveConf.set(AWS_GLUE_CONNECTION_TIMEOUT_KEY, String.valueOf(awsGlueConnectionTimeout)); | ||
|
|
@@ -109,6 +108,17 @@ private void initHiveConf() { | |
| hiveConf.set(AWS_CATALOG_CREDENTIALS_PROVIDER_FACTORY_CLASS_KEY, | ||
| "com.amazonaws.glue.catalog.credentials.ConfigurationAWSCredentialsProviderFactory"); | ||
| hiveConf.set("hive.metastore.type", "glue"); | ||
| setHiveConfPropertiesIfNotNull(hiveConf, AWSGlueConfig.AWS_GLUE_ACCESS_KEY, baseProperties.glueAccessKey); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to check if ak sk is set or not?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the authentication parameters are already validated during the initialization phase, we only need to perform null checks during usage. |
||
| setHiveConfPropertiesIfNotNull(hiveConf, AWSGlueConfig.AWS_GLUE_SECRET_KEY, baseProperties.glueSecretKey); | ||
| setHiveConfPropertiesIfNotNull(hiveConf, AWSGlueConfig.AWS_GLUE_SESSION_TOKEN, baseProperties.glueSessionToken); | ||
| setHiveConfPropertiesIfNotNull(hiveConf, AWSGlueConfig.AWS_GLUE_ROLE_ARN, baseProperties.glueIAMRole); | ||
| setHiveConfPropertiesIfNotNull(hiveConf, AWSGlueConfig.AWS_GLUE_EXTERNAL_ID, baseProperties.glueExternalId); | ||
| } | ||
|
|
||
| private static void setHiveConfPropertiesIfNotNull(HiveConf hiveConf, String key, String value) { | ||
| if (value != null) { | ||
| hiveConf.set(key, value); | ||
| } | ||
| } | ||
|
|
||
| public HMSGlueMetaStoreProperties(Map<String, String> origProps) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,11 +83,31 @@ private void appendS3Props(Map<String, String> props) { | |
|
|
||
| private void appendGlueProps(Map<String, String> props) { | ||
| props.put(AwsProperties.GLUE_CATALOG_ENDPOINT, glueProperties.glueEndpoint); | ||
| props.put("client.credentials-provider", | ||
| "com.amazonaws.glue.catalog.credentials.ConfigurationAWSCredentialsProvider2x"); | ||
| props.put("client.credentials-provider.glue.access_key", glueProperties.glueAccessKey); | ||
| props.put("client.credentials-provider.glue.secret_key", glueProperties.glueSecretKey); | ||
| props.put("aws.catalog.credentials.provider.factory.class", | ||
| "com.amazonaws.glue.catalog.credentials.ConfigurationAWSCredentialsProviderFactory"); | ||
|
|
||
| if (StringUtils.isNotBlank(glueProperties.glueAccessKey) && StringUtils | ||
| .isNotBlank(glueProperties.glueSecretKey)) { | ||
| props.put("client.credentials-provider", | ||
| "com.amazonaws.glue.catalog.credentials.ConfigurationAWSCredentialsProvider2x"); | ||
| props.put("client.credentials-provider.glue.access_key", glueProperties.glueAccessKey); | ||
| props.put("client.credentials-provider.glue.secret_key", glueProperties.glueSecretKey); | ||
| props.put("aws.catalog.credentials.provider.factory.class", | ||
| "com.amazonaws.glue.catalog.credentials.ConfigurationAWSCredentialsProviderFactory"); | ||
| if (StringUtils.isNotBlank(glueProperties.glueSessionToken)) { | ||
| props.put("client.credentials-provider.glue.session_token", glueProperties.glueSessionToken); | ||
| } | ||
| return; | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It’s just a personal preference—readability is much better this way, and deeply nested if/else statements aren’t very readable. |
||
| //IAM Assume Role | ||
| if (StringUtils.isNotBlank(glueProperties.glueIAMRole)) { | ||
| props.put(AwsProperties.CLIENT_FACTORY, | ||
| "org.apache.iceberg.aws.AssumeRoleAwsClientFactory"); | ||
| props.put("aws.region", glueProperties.glueRegion); | ||
|
|
||
| props.put(AwsProperties.CLIENT_ASSUME_ROLE_ARN, glueProperties.glueIAMRole); | ||
| props.put(AwsProperties.CLIENT_ASSUME_ROLE_REGION, glueProperties.glueRegion); | ||
| if (StringUtils.isNotBlank(glueProperties.glueExternalId)) { | ||
| props.put(AwsProperties.CLIENT_ASSUME_ROLE_EXTERNAL_ID, glueProperties.glueExternalId); | ||
| } | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.