michaelrommel commented on issue #4903:
URL: https://github.com/apache/opendal/issues/4903#issuecomment-3839989099

   Here is a temporary solution:
   
   ```rust
   use aws_config::meta::region::RegionProviderChain;
   use aws_credential_types::provider::ProvideCredentials;
   use aws_types::SdkConfig;
   
   struct AwsCredentialLoad;
   
   #[async_trait::async_trait]
   impl reqsign::AwsCredentialLoad for AwsCredentialLoad {
       async fn load_credential(&self, _client: Client) -> 
anyhow::Result<Option<AwsCredential>> {
           println!("Loading AWS credentials");
           let region_provider = 
RegionProviderChain::default_provider().or_else("us-east-1");
   
           let config: SdkConfig = 
aws_config::defaults(BehaviorVersion::v2026_01_12())
               .region(region_provider)
               .load()
               .await;
   
           if let Some(credentials_provider) = config.credentials_provider() {
               let credentials = 
credentials_provider.provide_credentials().await?;
               let duration = credentials
                   .expiry()
                   .unwrap()
                   .duration_since(UNIX_EPOCH)
                   .expect("SystemTime is before UNIX_EPOCH");
               let expiry = Utc
                   .timestamp_opt(duration.as_secs() as i64, 
duration.subsec_nanos())
                   .single();
               println!("AWS Token expires at: {:?}", expiry);
               return Ok(Some(AwsCredential {
                   access_key_id: credentials.access_key_id().to_string(),
                   secret_access_key: 
credentials.secret_access_key().to_string(),
                   session_token: credentials.session_token().map(|s| 
s.to_string()),
                   expires_in: expiry,
               }));
           }
           Ok(None)
       }
   }
   
      let builder = S3::default()
           .customized_credential_load(Box::new(AwsCredentialLoad))
           .endpoint("https://s3.amazonaws.com";)
           .region(&region) // String with the region name
           .bucket(&bucket) // String with the bucket name
           .root("/");
   ```
   


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

Reply via email to