manuzhang commented on code in PR #2396:
URL: https://github.com/apache/iceberg-rust/pull/2396#discussion_r3600345896


##########
crates/integrations/aws/src/config.rs:
##########
@@ -0,0 +1,449 @@
+// 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.
+
+//! AWS SDK configuration utilities.
+
+use std::collections::HashMap;
+use std::time::{Duration, SystemTime, UNIX_EPOCH};
+
+use aws_config::sts::AssumeRoleProvider;
+use aws_config::{BehaviorVersion, Region, SdkConfig};
+use aws_credential_types::Credentials as AwsSdkCredentials;
+use aws_credential_types::provider::{
+    ProvideCredentials, SharedCredentialsProvider, future as 
credentials_future,
+};
+use aws_sdk_sts::config::Credentials;
+use iceberg::io::{
+    S3_ACCESS_KEY_ID, S3_ASSUME_ROLE_ARN, S3_ASSUME_ROLE_EXTERNAL_ID, 
S3_ASSUME_ROLE_SESSION_NAME,
+    S3_ENDPOINT, S3_REGION, S3_SECRET_ACCESS_KEY, S3_SESSION_TOKEN,
+};
+use reqsign_aws_v4::Credential as AwsCredential;
+use reqsign_core::time::Timestamp;
+use reqsign_core::{Context, Error as ReqsignError, ProvideCredential};
+
+use crate::{
+    AWS_ACCESS_KEY_ID, AWS_ASSUME_ROLE_ARN, AWS_ASSUME_ROLE_EXTERNAL_ID,
+    AWS_ASSUME_ROLE_SESSION_NAME, AWS_PROFILE_NAME, AWS_REGION_NAME, 
AWS_SECRET_ACCESS_KEY,
+    AWS_SESSION_TOKEN,
+};
+
+/// Creates an AWS SDK configuration from catalog properties.
+///
+/// When `client.assume-role.arn` is set, the configured base credentials,
+/// profile, region, and runtime settings are used for the STS request. The
+/// returned configuration uses the refreshable assumed-role provider.
+pub async fn create_sdk_config(
+    properties: &HashMap<String, String>,
+    endpoint_uri: Option<&str>,
+    default_session_name: &str,
+) -> SdkConfig {
+    let mut loader = aws_config::defaults(BehaviorVersion::latest());
+
+    if let Some(endpoint) = endpoint_uri {

Review Comment:
   This adds the Glue/S3Tables endpoint to `base_config`, which is then passed 
to `AssumeRoleProvider`. Consequently, AssumeRole requests are sent to the 
catalog endpoint. This fails when the configured endpoint implements only Glue 
or S3Tables rather than STS. Build the STS base configuration without the 
catalog endpoint, then apply that endpoint only to the returned service 
configuration.



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