From 10e915b6aca8e8c3c5f8ba245ab823696822b616 Mon Sep 17 00:00:00 2001 From: ysaito1001 Date: Thu, 19 Jan 2023 10:48:55 -0600 Subject: [PATCH] Replace Arc with SharedCredentialsProvider in credentials_provider builder methods (#2227) * Stop exposing `Arc` in `credentials_provider` builder methods This commit rectifies the signature changes made to `credentials_provider` builder methods in https://github.com/awslabs/smithy-rs/pull/2122. The PR in question removed `SharedCredentialsProvider` and the builder methods started taking `ProvideCredentials` in `Arc` instead. This causes a problem for us to evolve the API in the future as the API forces the user to be aware of the implementation detail that we use `Arc`. * Update comments for `SharedCredentialsCache` * Fix unresolved doc links to `ProvideCredentials` This commit fixes unresolved doc links to `ProvideCredentials` in `aws_credential_types::lazy_caching`. * Update CHANGELOG.next.toml Co-authored-by: Yuki Saito --- CHANGELOG.next.toml | 19 ++++------ .../aws-config/external-types.toml | 1 + aws/rust-runtime/aws-config/src/lib.rs | 13 +++---- .../aws-credential-types/src/cache.rs | 14 +++---- .../src/cache/lazy_caching.rs | 28 +++++++------- .../aws-credential-types/src/provider.rs | 38 +++++++++++++++++++ aws/rust-runtime/aws-http/src/auth.rs | 8 ++-- .../tests/middleware_e2e_test.rs | 5 ++- .../aws-types/external-types.toml | 2 +- aws/rust-runtime/aws-types/src/sdk_config.rs | 24 ++++++------ .../amazon/smithy/rustsdk/CredentialCaches.kt | 3 +- .../smithy/rustsdk/CredentialProviders.kt | 15 +++----- .../dynamodb/tests/cloning.rs | 5 +-- .../dynamodb/tests/timeouts.rs | 5 ++- .../s3/tests/alternative-async-runtime.rs | 3 +- .../integration-tests/s3/tests/checksums.rs | 6 +-- .../integration-tests/s3/tests/concurrency.rs | 5 ++- .../s3/tests/customizable-operation.rs | 4 +- .../integration-tests/s3/tests/endpoints.rs | 4 +- .../s3/tests/ignore-invalid-xml-body-root.rs | 4 +- .../s3/tests/naughty-string-metadata.rs | 4 +- .../s3/tests/normalize-uri-path.rs | 4 +- .../query-strings-are-correctly-encoded.rs | 4 +- .../s3/tests/recursion-detection.rs | 4 +- .../s3/tests/select-object-content.rs | 4 +- .../integration-tests/s3/tests/signing-it.rs | 4 +- .../s3/tests/streaming-response.rs | 4 +- .../integration-tests/s3/tests/timeouts.rs | 7 ++-- .../s3/tests/user-agent-app-name.rs | 4 +- .../s3control/tests/signing-it.rs | 4 +- 30 files changed, 142 insertions(+), 107 deletions(-) diff --git a/CHANGELOG.next.toml b/CHANGELOG.next.toml index 4e1040e015..e13a16fc49 100644 --- a/CHANGELOG.next.toml +++ b/CHANGELOG.next.toml @@ -155,7 +155,6 @@ After: ```rust use aws_credential_types::cache::CredentialsCache; use aws_types::provider::ProvideCredentials; -use std::sync::Arc; fn make_provider() -> impl ProvideCredentials { // --snip-- @@ -164,7 +163,7 @@ fn make_provider() -> impl ProvideCredentials { // Wrapping a result of `make_provider` in `LazyCredentialsCache` is done automatically. let sdk_config = aws_config::from_env() .credentials_cache(CredentialsCache::lazy()) // This line can be omitted because it is on by default. - .credentials_provider(Arc::new(make_provider())) + .credentials_provider(make_provider()) .load() .await; @@ -201,7 +200,6 @@ After: ```rust use aws_credential_types::cache::CredentialsCache; use aws_types::provider::ProvideCredentials; -use std::sync::Arc; use std::time::Duration; fn make_provider() -> impl ProvideCredentials { @@ -214,7 +212,7 @@ let sdk_config = aws_config::from_env() .load_timeout(Duration::from_secs(60)) // Configures timeout. .into_credentials_cache(), ) - .credentials_provider(Arc::new(make_provider())) + .credentials_provider(make_provider()) .load() .await; @@ -253,7 +251,6 @@ After: ```rust use aws_config::default_provider::credentials::default_provider; use aws_credential_types::cache::CredentialsCache; -use std::sync::Arc; use std::time::Duration; // Previously used methods no longer exist on the builder for `DefaultCredentialsChain`. @@ -266,7 +263,7 @@ let sdk_config = aws_config::from_env() .default_credential_expiration(Duration::from_secs(20 * 60)) .into_credentials_cache(), ) - .credentials_provider(Arc::new(credentials_provider)) + .credentials_provider(credentials_provider) .load() .await; @@ -275,13 +272,13 @@ let client = aws_sdk_s3::Client::new(&sdk_config); """ -references = ["smithy-rs#2122"] +references = ["smithy-rs#2122", "smithy-rs#2227"] meta = { "breaking" = true, "tada" = false, "bug" = false } author = "ysaito1001" [[aws-sdk-rust]] message = """ -The introduction of `CredentialsCache` comes with an accompanying type `SharedCredentialsCache`. This replaces `SharedCredentialsProvider` and as a result, `aws_http::auth:set_provider` has been updated to `aws_http::auth::set_credentials_cache`. +The introduction of `CredentialsCache` comes with an accompanying type `SharedCredentialsCache`, which we will store in the property bag instead of a `SharedCredentialsProvider`. As a result, `aws_http::auth:set_provider` has been updated to `aws_http::auth::set_credentials_cache`. Before: ```rust @@ -303,23 +300,23 @@ After: ```rust use aws_credential_types::Credentials; use aws_credential_types::cache::{CredentialsCache, SharedCredentialsCache}; +use aws_credential_types::provider::SharedCredentialsProvider; use aws_http::auth::set_credentials_cache; use aws_smithy_http::body::SdkBody; use aws_smithy_http::operation; -use std::sync::Arc; let mut req = operation::Request::new(http::Request::new(SdkBody::from("some body"))); let credentials = Credentials::new("example", "example", None, None, "my_provider_name"); let credentials_cache = CredentialsCache::lazy_builder() .into_credentials_cache() - .create_cache(Arc::new(credentials)); + .create_cache(SharedCredentialsProvider::new(credentials)); set_credentials_cache( &mut req.properties_mut(), SharedCredentialsCache::new(credentials_cache), ); ``` """ -references = ["smithy-rs#2122"] +references = ["smithy-rs#2122", "smithy-rs#2227"] meta = { "breaking" = true, "tada" = false, "bug" = false } author = "ysaito1001" diff --git a/aws/rust-runtime/aws-config/external-types.toml b/aws/rust-runtime/aws-config/external-types.toml index e47352e151..9a7dbc128e 100644 --- a/aws/rust-runtime/aws-config/external-types.toml +++ b/aws/rust-runtime/aws-config/external-types.toml @@ -6,6 +6,7 @@ allowed_external_types = [ "aws_credential_types::cache::CredentialsCache", "aws_credential_types::provider::ProvideCredentials", "aws_credential_types::provider::Result", + "aws_credential_types::provider::SharedCredentialsProvider", "aws_sdk_sts::model::PolicyDescriptorType", "aws_smithy_async::rt::sleep::AsyncSleep", "aws_smithy_client::bounds::SmithyConnector", diff --git a/aws/rust-runtime/aws-config/src/lib.rs b/aws/rust-runtime/aws-config/src/lib.rs index d1b93f8993..8ca695a770 100644 --- a/aws/rust-runtime/aws-config/src/lib.rs +++ b/aws/rust-runtime/aws-config/src/lib.rs @@ -151,7 +151,7 @@ mod loader { use std::sync::Arc; use aws_credential_types::cache::CredentialsCache; - use aws_credential_types::provider::ProvideCredentials; + use aws_credential_types::provider::{ProvideCredentials, SharedCredentialsProvider}; use aws_smithy_async::rt::sleep::{default_async_sleep, AsyncSleep}; use aws_smithy_client::http_connector::{ConnectorSettings, HttpConnector}; use aws_smithy_types::retry::RetryConfig; @@ -179,7 +179,7 @@ mod loader { pub struct ConfigLoader { app_name: Option, credentials_cache: Option, - credentials_provider: Option>, + credentials_provider: Option, endpoint_resolver: Option>, endpoint_url: Option, region: Option>, @@ -326,22 +326,21 @@ mod loader { /// Override the credentials provider but load the default value for region: /// ```no_run /// # use aws_credential_types::Credentials; - /// # use std::sync::Arc; /// # fn create_my_credential_provider() -> Credentials { /// # Credentials::new("example", "example", None, None, "example") /// # } /// # async fn create_config() { /// let config = aws_config::from_env() - /// .credentials_provider(Arc::new(create_my_credential_provider())) + /// .credentials_provider(create_my_credential_provider()) /// .load() /// .await; /// # } /// ``` pub fn credentials_provider( mut self, - credentials_provider: Arc, + credentials_provider: impl ProvideCredentials + 'static, ) -> Self { - self.credentials_provider = Some(credentials_provider); + self.credentials_provider = Some(SharedCredentialsProvider::new(credentials_provider)); self } @@ -600,7 +599,7 @@ mod loader { } else { let mut builder = credentials::DefaultCredentialsChain::builder().configure(conf); builder.set_region(region.clone()); - Arc::new(builder.build().await) + SharedCredentialsProvider::new(builder.build().await) }; let endpoint_resolver = self.endpoint_resolver; diff --git a/aws/rust-runtime/aws-credential-types/src/cache.rs b/aws/rust-runtime/aws-credential-types/src/cache.rs index 6a6c740d06..23e90c48fa 100644 --- a/aws/rust-runtime/aws-credential-types/src/cache.rs +++ b/aws/rust-runtime/aws-credential-types/src/cache.rs @@ -11,7 +11,7 @@ mod lazy_caching; pub use expiring_cache::ExpiringCache; pub use lazy_caching::Builder as LazyBuilder; -use crate::provider::{future, ProvideCredentials}; +use crate::provider::{future, SharedCredentialsProvider}; use std::sync::Arc; /// Asynchronous Cached Credentials Provider @@ -24,13 +24,13 @@ pub trait ProvideCachedCredentials: Send + Sync + std::fmt::Debug { /// Credentials cache wrapper that may be shared /// -/// Newtype wrapper around ProvideCachedCredentials that implements Clone using an internal -/// Arc. +/// Newtype wrapper around `ProvideCachedCredentials` that implements `Clone` using an internal +/// `Arc`. #[derive(Clone, Debug)] pub struct SharedCredentialsCache(Arc); impl SharedCredentialsCache { - /// Create a new `SharedCredentialsCache` from `ProvideCredentialsCache` + /// Create a new `SharedCredentialsCache` from `ProvideCachedCredentials` /// /// The given `cache` will be wrapped in an internal `Arc`. If your /// cache is already in an `Arc`, use `SharedCredentialsCache::from(cache)` instead. @@ -73,11 +73,11 @@ pub(crate) enum Inner { /// use aws_credential_types::Credentials; /// use aws_credential_types::cache::CredentialsCache; /// use aws_credential_types::credential_fn::provide_credentials_fn; -/// use std::sync::Arc; +/// use aws_credential_types::provider::SharedCredentialsProvider; /// /// let credentials_cache = CredentialsCache::lazy_builder() /// .into_credentials_cache() -/// .create_cache(Arc::new(provide_credentials_fn(|| async { +/// .create_cache(SharedCredentialsProvider::new(provide_credentials_fn(|| async { /// // An async process to retrieve credentials would go here: /// Ok(Credentials::new( /// "example", @@ -105,7 +105,7 @@ impl CredentialsCache { } /// Creates a [`SharedCredentialsCache`] wrapping a concrete caching implementation. - pub fn create_cache(self, provider: Arc) -> SharedCredentialsCache { + pub fn create_cache(self, provider: SharedCredentialsProvider) -> SharedCredentialsCache { match self.inner { Inner::Lazy(builder) => SharedCredentialsCache::new(builder.build(provider)), } diff --git a/aws/rust-runtime/aws-credential-types/src/cache/lazy_caching.rs b/aws/rust-runtime/aws-credential-types/src/cache/lazy_caching.rs index c448e862bd..d0484fc081 100644 --- a/aws/rust-runtime/aws-credential-types/src/cache/lazy_caching.rs +++ b/aws/rust-runtime/aws-credential-types/src/cache/lazy_caching.rs @@ -13,6 +13,7 @@ use aws_smithy_async::rt::sleep::AsyncSleep; use tracing::{debug, info, info_span, Instrument}; use crate::cache::{ExpiringCache, ProvideCachedCredentials}; +use crate::provider::SharedCredentialsProvider; use crate::provider::{error::CredentialsError, future, ProvideCredentials}; use crate::time_source::TimeSource; @@ -25,7 +26,7 @@ pub(crate) struct LazyCredentialsCache { time: TimeSource, sleeper: Arc, cache: ExpiringCache, - provider: Arc, + provider: SharedCredentialsProvider, load_timeout: Duration, default_credential_expiration: Duration, } @@ -34,7 +35,7 @@ impl LazyCredentialsCache { fn new( time: TimeSource, sleeper: Arc, - provider: Arc, + provider: SharedCredentialsProvider, load_timeout: Duration, default_credential_expiration: Duration, buffer_time: Duration, @@ -110,7 +111,7 @@ mod builder { use std::time::Duration; use crate::cache::{CredentialsCache, Inner}; - use crate::provider::ProvideCredentials; + use crate::provider::SharedCredentialsProvider; use aws_smithy_async::rt::sleep::{default_async_sleep, AsyncSleep}; use super::TimeSource; @@ -122,9 +123,9 @@ mod builder { /// Builder for constructing a `LazyCredentialsCache`. /// /// `LazyCredentialsCache` implements [`ProvideCachedCredentials`](crate::cache::ProvideCachedCredentials) by caching - /// credentials that it loads by calling a user-provided [`ProvideCredentials`] implementation. + /// credentials that it loads by calling a user-provided [`ProvideCredentials`](crate::provider::ProvideCredentials) implementation. /// - /// For example, you can provide a [`ProvideCredentials`] implementation that calls + /// For example, you can provide a [`ProvideCredentials`](crate::provider::ProvideCredentials) implementation that calls /// AWS STS's AssumeRole operation to get temporary credentials, and `LazyCredentialsCache` /// will cache those credentials until they expire. /// @@ -178,7 +179,7 @@ mod builder { self } - /// Timeout for the given [`ProvideCredentials`] implementation. + /// Timeout for the given [`ProvideCredentials`](crate::provider::ProvideCredentials) implementation. /// /// Defaults to 5 seconds. pub fn load_timeout(mut self, timeout: Duration) -> Self { @@ -186,7 +187,7 @@ mod builder { self } - /// Timeout for the given [`ProvideCredentials`] implementation. + /// Timeout for the given [`ProvideCredentials`](crate::provider::ProvideCredentials) implementation. /// /// Defaults to 5 seconds. pub fn set_load_timeout(&mut self, timeout: Option) -> &mut Self { @@ -220,7 +221,7 @@ mod builder { /// Default expiration time to set on credentials if they don't have an expiration time. /// - /// This is only used if the given [`ProvideCredentials`] returns + /// This is only used if the given [`ProvideCredentials`](crate::provider::ProvideCredentials) returns /// [`Credentials`](crate::Credentials) that don't have their `expiry` set. /// This must be at least 15 minutes. /// @@ -232,7 +233,7 @@ mod builder { /// Default expiration time to set on credentials if they don't have an expiration time. /// - /// This is only used if the given [`ProvideCredentials`] returns + /// This is only used if the given [`ProvideCredentials`](crate::provider::ProvideCredentials) returns /// [`Credentials`](crate::Credentials) that don't have their `expiry` set. /// This must be at least 15 minutes. /// @@ -258,7 +259,7 @@ mod builder { /// This will panic if no `sleep` implementation is given and if no default crate features /// are used. By default, the [`TokioSleep`](aws_smithy_async::rt::sleep::TokioSleep) /// implementation will be set automatically. - pub(crate) fn build(self, provider: Arc) -> LazyCredentialsCache { + pub(crate) fn build(self, provider: SharedCredentialsProvider) -> LazyCredentialsCache { let default_credential_expiration = self .default_credential_expiration .unwrap_or(DEFAULT_CREDENTIAL_EXPIRATION); @@ -289,6 +290,7 @@ mod tests { use tracing::info; use tracing_test::traced_test; + use crate::provider::SharedCredentialsProvider; use crate::{ cache::ProvideCachedCredentials, credential_fn::provide_credentials_fn, provider::error::CredentialsError, time_source::TestingTimeSource, Credentials, @@ -307,7 +309,7 @@ mod tests { LazyCredentialsCache::new( time, Arc::new(TokioSleep::new()), - Arc::new(provide_credentials_fn(move || { + SharedCredentialsProvider::new(provide_credentials_fn(move || { let list = load_list.clone(); async move { let next = list.lock().unwrap().remove(0); @@ -341,7 +343,7 @@ mod tests { #[tokio::test] async fn initial_populate_credentials() { let time = TestingTimeSource::new(UNIX_EPOCH); - let provider = Arc::new(provide_credentials_fn(|| async { + let provider = SharedCredentialsProvider::new(provide_credentials_fn(|| async { info!("refreshing the credentials"); Ok(credentials(1000)) })); @@ -464,7 +466,7 @@ mod tests { let credentials_cache = LazyCredentialsCache::new( TimeSource::testing(&time), Arc::new(TokioSleep::new()), - Arc::new(provide_credentials_fn(|| async { + SharedCredentialsProvider::new(provide_credentials_fn(|| async { aws_smithy_async::future::never::Never::new().await; Ok(credentials(1000)) })), diff --git a/aws/rust-runtime/aws-credential-types/src/provider.rs b/aws/rust-runtime/aws-credential-types/src/provider.rs index 497887597c..7f0e6282f1 100644 --- a/aws/rust-runtime/aws-credential-types/src/provider.rs +++ b/aws/rust-runtime/aws-credential-types/src/provider.rs @@ -299,3 +299,41 @@ impl ProvideCredentials for Arc { self.as_ref().provide_credentials() } } + +/// Credentials Provider wrapper that may be shared +/// +/// Newtype wrapper around ProvideCredentials that implements Clone using an internal +/// Arc. +#[derive(Clone, Debug)] +pub struct SharedCredentialsProvider(Arc); + +impl SharedCredentialsProvider { + /// Create a new SharedCredentials provider from `ProvideCredentials` + /// + /// The given provider will be wrapped in an internal `Arc`. If your + /// provider is already in an `Arc`, use `SharedCredentialsProvider::from(provider)` instead. + pub fn new(provider: impl ProvideCredentials + 'static) -> Self { + Self(Arc::new(provider)) + } +} + +impl AsRef for SharedCredentialsProvider { + fn as_ref(&self) -> &(dyn ProvideCredentials + 'static) { + self.0.as_ref() + } +} + +impl From> for SharedCredentialsProvider { + fn from(provider: Arc) -> Self { + SharedCredentialsProvider(provider) + } +} + +impl ProvideCredentials for SharedCredentialsProvider { + fn provide_credentials<'a>(&'a self) -> future::ProvideCredentials<'a> + where + Self: 'a, + { + self.0.provide_credentials() + } +} diff --git a/aws/rust-runtime/aws-http/src/auth.rs b/aws/rust-runtime/aws-http/src/auth.rs index 97d943f1d8..c91b4c5bb5 100644 --- a/aws/rust-runtime/aws-http/src/auth.rs +++ b/aws/rust-runtime/aws-http/src/auth.rs @@ -116,12 +116,12 @@ mod tests { CredentialsCache, ProvideCachedCredentials, SharedCredentialsCache, }; use aws_credential_types::credential_fn::provide_credentials_fn; + use aws_credential_types::provider::SharedCredentialsProvider; use aws_credential_types::provider::{error::CredentialsError, future}; use aws_credential_types::Credentials; use aws_smithy_http::body::SdkBody; use aws_smithy_http::middleware::AsyncMapRequest; use aws_smithy_http::operation; - use std::sync::Arc; #[derive(Debug)] struct Unhandled; @@ -185,9 +185,9 @@ mod tests { let mut req = operation::Request::new(http::Request::new(SdkBody::from("some body"))); let credentials_cache = CredentialsCache::lazy_builder() .into_credentials_cache() - .create_cache(Arc::new(provide_credentials_fn(|| async { - Ok(Credentials::for_tests()) - }))); + .create_cache(SharedCredentialsProvider::new(provide_credentials_fn( + || async { Ok(Credentials::for_tests()) }, + ))); set_credentials_cache( &mut req.properties_mut(), SharedCredentialsCache::from(credentials_cache), diff --git a/aws/rust-runtime/aws-inlineable/tests/middleware_e2e_test.rs b/aws/rust-runtime/aws-inlineable/tests/middleware_e2e_test.rs index 04fd7ca61a..29db9af0fa 100644 --- a/aws/rust-runtime/aws-inlineable/tests/middleware_e2e_test.rs +++ b/aws/rust-runtime/aws-inlineable/tests/middleware_e2e_test.rs @@ -7,10 +7,10 @@ use std::convert::Infallible; use std::error::Error; use std::fmt; use std::fmt::{Display, Formatter}; -use std::sync::Arc; use std::time::{Duration, UNIX_EPOCH}; use aws_credential_types::cache::CredentialsCache; +use aws_credential_types::provider::SharedCredentialsProvider; use aws_credential_types::Credentials; use aws_smithy_client::erase::DynConnector; use aws_smithy_client::test_connection::TestConnection; @@ -88,7 +88,8 @@ fn test_operation() -> Operation, credentials_cache: Option, - credentials_provider: Option>, + credentials_provider: Option, region: Option, endpoint_resolver: Option>, endpoint_url: Option, @@ -70,7 +70,7 @@ pub struct SdkConfig { pub struct Builder { app_name: Option, credentials_cache: Option, - credentials_provider: Option>, + credentials_provider: Option, region: Option, endpoint_resolver: Option>, endpoint_url: Option, @@ -382,9 +382,8 @@ impl Builder { /// /// # Examples /// ```rust - /// use aws_credential_types::provider::ProvideCredentials; + /// use aws_credential_types::provider::{ProvideCredentials, SharedCredentialsProvider}; /// use aws_types::SdkConfig; - /// use std::sync::Arc; /// fn make_provider() -> impl ProvideCredentials { /// // ... /// # use aws_credential_types::Credentials; @@ -392,10 +391,10 @@ impl Builder { /// } /// /// let config = SdkConfig::builder() - /// .credentials_provider(Arc::new(make_provider())) + /// .credentials_provider(SharedCredentialsProvider::new(make_provider())) /// .build(); /// ``` - pub fn credentials_provider(mut self, provider: Arc) -> Self { + pub fn credentials_provider(mut self, provider: SharedCredentialsProvider) -> Self { self.set_credentials_provider(Some(provider)); self } @@ -404,9 +403,8 @@ impl Builder { /// /// # Examples /// ```rust - /// use aws_credential_types::provider::ProvideCredentials; + /// use aws_credential_types::provider::{ProvideCredentials, SharedCredentialsProvider}; /// use aws_types::SdkConfig; - /// use std::sync::Arc; /// fn make_provider() -> impl ProvideCredentials { /// // ... /// # use aws_credential_types::Credentials; @@ -420,13 +418,13 @@ impl Builder { /// /// let mut builder = SdkConfig::builder(); /// if override_provider() { - /// builder.set_credentials_provider(Some(Arc::new(make_provider()))); + /// builder.set_credentials_provider(Some(SharedCredentialsProvider::new(make_provider()))); /// } /// let config = builder.build(); /// ``` pub fn set_credentials_provider( &mut self, - provider: Option>, + provider: Option, ) -> &mut Self { self.credentials_provider = provider; self @@ -609,8 +607,8 @@ impl SdkConfig { } /// Configured credentials provider - pub fn credentials_provider(&self) -> Option> { - self.credentials_provider.clone() + pub fn credentials_provider(&self) -> Option<&SharedCredentialsProvider> { + self.credentials_provider.as_ref() } /// Configured app name diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialCaches.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialCaches.kt index 15e49945e3..03f22cb21f 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialCaches.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialCaches.kt @@ -54,6 +54,7 @@ class CredentialsCacheDecorator : ClientCodegenDecorator { class CredentialCacheConfig(runtimeConfig: RuntimeConfig) : ConfigCustomization() { private val codegenScope = arrayOf( "cache" to AwsRuntimeType.awsCredentialTypes(runtimeConfig).resolve("cache"), + "provider" to AwsRuntimeType.awsCredentialTypes(runtimeConfig).resolve("provider"), "DefaultProvider" to defaultProvider(), ) @@ -113,7 +114,7 @@ class CredentialCacheConfig(runtimeConfig: RuntimeConfig) : ConfigCustomization( }) .create_cache( self.credentials_provider.unwrap_or_else(|| { - std::sync::Arc::new(#{DefaultProvider}) + #{provider}::SharedCredentialsProvider::new(#{DefaultProvider}) }) ), """, diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialProviders.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialProviders.kt index 79b534ccd6..dc6f8e9d0a 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialProviders.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/CredentialProviders.kt @@ -44,7 +44,7 @@ class CredentialsProviderDecorator : ClientCodegenDecorator { listOf( SdkConfigSection.create { section -> writable { - rust("${section.serviceConfigBuilder}.set_credentials_provider(${section.sdkConfig}.credentials_provider().clone());") + rust("${section.serviceConfigBuilder}.set_credentials_provider(${section.sdkConfig}.credentials_provider().cloned());") } }, ) @@ -62,28 +62,23 @@ class CredentialProviderConfig(runtimeConfig: RuntimeConfig) : ConfigCustomizati "provider" to AwsRuntimeType.awsCredentialTypes(runtimeConfig).resolve("provider"), "Credentials" to AwsRuntimeType.awsCredentialTypes(runtimeConfig).resolve("Credentials"), "TestCredentials" to AwsRuntimeType.awsCredentialTypesTestUtil(runtimeConfig).resolve("Credentials"), - "DefaultProvider" to defaultProvider(), ) override fun section(section: ServiceConfig) = writable { when (section) { ServiceConfig.BuilderStruct -> - rustTemplate( - "credentials_provider: Option>,", - *codegenScope, - ) - + rustTemplate("credentials_provider: Option<#{provider}::SharedCredentialsProvider>,", *codegenScope) ServiceConfig.BuilderImpl -> { rustTemplate( """ /// Sets the credentials provider for this service pub fn credentials_provider(mut self, credentials_provider: impl #{provider}::ProvideCredentials + 'static) -> Self { - self.set_credentials_provider(Some(std::sync::Arc::new(credentials_provider))); + self.set_credentials_provider(Some(#{provider}::SharedCredentialsProvider::new(credentials_provider))); self } /// Sets the credentials provider for this service - pub fn set_credentials_provider(&mut self, credentials_provider: Option>) -> &mut Self { + pub fn set_credentials_provider(&mut self, credentials_provider: Option<#{provider}::SharedCredentialsProvider>) -> &mut Self { self.credentials_provider = credentials_provider; self } @@ -93,7 +88,7 @@ class CredentialProviderConfig(runtimeConfig: RuntimeConfig) : ConfigCustomizati } is ServiceConfig.DefaultForTests -> rustTemplate( - "${section.configBuilderRef}.set_credentials_provider(Some(std::sync::Arc::new(#{TestCredentials}::for_tests())));", + "${section.configBuilderRef}.set_credentials_provider(Some(#{provider}::SharedCredentialsProvider::new(#{TestCredentials}::for_tests())));", *codegenScope, ) diff --git a/aws/sdk/integration-tests/dynamodb/tests/cloning.rs b/aws/sdk/integration-tests/dynamodb/tests/cloning.rs index c48a6d3bf7..34bb09a0c5 100644 --- a/aws/sdk/integration-tests/dynamodb/tests/cloning.rs +++ b/aws/sdk/integration-tests/dynamodb/tests/cloning.rs @@ -3,16 +3,15 @@ * SPDX-License-Identifier: Apache-2.0 */ -use aws_credential_types::Credentials; +use aws_credential_types::{provider::SharedCredentialsProvider, Credentials}; use aws_types::region::Region; -use std::sync::Arc; // compiling this function validates that fluent builders are cloneable #[allow(dead_code)] async fn ensure_builders_clone() { let shared_config = aws_types::SdkConfig::builder() .region(Region::new("us-east-4")) - .credentials_provider(Arc::new(Credentials::for_tests())) + .credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests())) .build(); let client = aws_sdk_dynamodb::Client::new(&shared_config); let base_query = client.list_tables(); diff --git a/aws/sdk/integration-tests/dynamodb/tests/timeouts.rs b/aws/sdk/integration-tests/dynamodb/tests/timeouts.rs index 683afe3aa9..5695b403d8 100644 --- a/aws/sdk/integration-tests/dynamodb/tests/timeouts.rs +++ b/aws/sdk/integration-tests/dynamodb/tests/timeouts.rs @@ -6,6 +6,7 @@ use std::sync::Arc; use std::time::Duration; +use aws_credential_types::provider::SharedCredentialsProvider; use aws_credential_types::Credentials; use aws_sdk_dynamodb::types::SdkError; use aws_smithy_async::rt::sleep::{AsyncSleep, Sleep}; @@ -29,7 +30,7 @@ async fn api_call_timeout_retries() { let conf = SdkConfig::builder() .region(Region::new("us-east-2")) .http_connector(conn.clone()) - .credentials_provider(Arc::new(Credentials::for_tests())) + .credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests())) .timeout_config( TimeoutConfig::builder() .operation_attempt_timeout(Duration::new(123, 0)) @@ -62,7 +63,7 @@ async fn no_retries_on_operation_timeout() { let conf = SdkConfig::builder() .region(Region::new("us-east-2")) .http_connector(conn.clone()) - .credentials_provider(Arc::new(Credentials::for_tests())) + .credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests())) .timeout_config( TimeoutConfig::builder() .operation_timeout(Duration::new(123, 0)) diff --git a/aws/sdk/integration-tests/s3/tests/alternative-async-runtime.rs b/aws/sdk/integration-tests/s3/tests/alternative-async-runtime.rs index df67026e9e..a1e44b2c7a 100644 --- a/aws/sdk/integration-tests/s3/tests/alternative-async-runtime.rs +++ b/aws/sdk/integration-tests/s3/tests/alternative-async-runtime.rs @@ -4,6 +4,7 @@ */ use aws_config::retry::RetryConfig; +use aws_credential_types::provider::SharedCredentialsProvider; use aws_sdk_s3::model::{ CompressionType, CsvInput, CsvOutput, ExpressionType, FileHeaderInfo, InputSerialization, OutputSerialization, @@ -127,7 +128,7 @@ async fn retry_test(sleep_impl: Arc) -> Result<(), Box( ) { let (conn, rcvr) = capture_request(None); let sdk_config = SdkConfig::builder() - .credentials_provider(Arc::new(Credentials::for_tests())) + .credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests())) .region(Region::new("us-east-1")) .http_connector(conn.clone()) .build(); diff --git a/aws/sdk/integration-tests/s3/tests/concurrency.rs b/aws/sdk/integration-tests/s3/tests/concurrency.rs index 29d9c8ae4e..c54d303d4b 100644 --- a/aws/sdk/integration-tests/s3/tests/concurrency.rs +++ b/aws/sdk/integration-tests/s3/tests/concurrency.rs @@ -8,6 +8,7 @@ use std::iter::repeat_with; use std::net::SocketAddr; use std::sync::Arc; +use aws_credential_types::provider::SharedCredentialsProvider; use aws_credential_types::Credentials; use aws_sdk_s3::Client; use aws_smithy_types::timeout::TimeoutConfig; @@ -42,7 +43,7 @@ async fn test_concurrency_on_multi_thread_against_dummy_server() { let (server, server_addr) = start_agreeable_server().await; let _ = tokio::spawn(server); let sdk_config = SdkConfig::builder() - .credentials_provider(Arc::new(Credentials::for_tests())) + .credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests())) .region(Region::new("us-east-1")) .endpoint_url(format!("http://{server_addr}")) .build(); @@ -55,7 +56,7 @@ async fn test_concurrency_on_single_thread_against_dummy_server() { let (server, server_addr) = start_agreeable_server().await; let _ = tokio::spawn(server); let sdk_config = SdkConfig::builder() - .credentials_provider(Arc::new(Credentials::for_tests())) + .credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests())) .region(Region::new("us-east-1")) .endpoint_url(format!("http://{server_addr}")) .build(); diff --git a/aws/sdk/integration-tests/s3/tests/customizable-operation.rs b/aws/sdk/integration-tests/s3/tests/customizable-operation.rs index 199b5edbb9..f0b584aa12 100644 --- a/aws/sdk/integration-tests/s3/tests/customizable-operation.rs +++ b/aws/sdk/integration-tests/s3/tests/customizable-operation.rs @@ -4,19 +4,19 @@ */ use aws_config::SdkConfig; +use aws_credential_types::provider::SharedCredentialsProvider; use aws_http::user_agent::AwsUserAgent; use aws_sdk_s3::{Client, Credentials, Region}; use aws_smithy_client::test_connection::capture_request; use std::convert::Infallible; -use std::sync::Arc; use std::time::{Duration, UNIX_EPOCH}; #[tokio::test] async fn test_s3_ops_are_customizable() { let (conn, rcvr) = capture_request(None); let sdk_config = SdkConfig::builder() - .credentials_provider(Arc::new(Credentials::for_tests())) + .credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests())) .region(Region::new("us-east-1")) .http_connector(conn.clone()) .build(); diff --git a/aws/sdk/integration-tests/s3/tests/endpoints.rs b/aws/sdk/integration-tests/s3/tests/endpoints.rs index d0a9f3501e..93c37f5c87 100644 --- a/aws/sdk/integration-tests/s3/tests/endpoints.rs +++ b/aws/sdk/integration-tests/s3/tests/endpoints.rs @@ -4,17 +4,17 @@ */ use aws_config::SdkConfig; +use aws_credential_types::provider::SharedCredentialsProvider; use aws_sdk_s3::config::Builder; use aws_sdk_s3::{Client, Credentials, Region}; use aws_smithy_client::test_connection::{capture_request, CaptureRequestReceiver}; use std::convert::Infallible; -use std::sync::Arc; use std::time::{Duration, UNIX_EPOCH}; fn test_client(update_builder: fn(Builder) -> Builder) -> (CaptureRequestReceiver, Client) { let (conn, captured_request) = capture_request(None); let sdk_config = SdkConfig::builder() - .credentials_provider(Arc::new(Credentials::for_tests())) + .credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests())) .region(Region::new("us-west-4")) .http_connector(conn.clone()) .build(); diff --git a/aws/sdk/integration-tests/s3/tests/ignore-invalid-xml-body-root.rs b/aws/sdk/integration-tests/s3/tests/ignore-invalid-xml-body-root.rs index 09e31930bf..e2f850cb68 100644 --- a/aws/sdk/integration-tests/s3/tests/ignore-invalid-xml-body-root.rs +++ b/aws/sdk/integration-tests/s3/tests/ignore-invalid-xml-body-root.rs @@ -3,6 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +use aws_credential_types::provider::SharedCredentialsProvider; use aws_http::user_agent::AwsUserAgent; use aws_sdk_s3::{model::ObjectAttributes, Client, Credentials, Region}; use aws_smithy_client::test_connection::TestConnection; @@ -11,7 +12,6 @@ use aws_types::SdkConfig; use http::header::AUTHORIZATION; use std::{ convert::Infallible, - sync::Arc, time::{Duration, UNIX_EPOCH}, }; @@ -46,7 +46,7 @@ async fn ignore_invalid_xml_body_root() { ]); let sdk_config = SdkConfig::builder() - .credentials_provider(Arc::new(Credentials::for_tests())) + .credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests())) .region(Region::new("us-east-1")) .http_connector(conn.clone()) .build(); diff --git a/aws/sdk/integration-tests/s3/tests/naughty-string-metadata.rs b/aws/sdk/integration-tests/s3/tests/naughty-string-metadata.rs index d00ce64036..fd537a539a 100644 --- a/aws/sdk/integration-tests/s3/tests/naughty-string-metadata.rs +++ b/aws/sdk/integration-tests/s3/tests/naughty-string-metadata.rs @@ -3,6 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +use aws_credential_types::provider::SharedCredentialsProvider; use aws_http::user_agent::AwsUserAgent; use aws_sdk_s3::{types::ByteStream, Client, Credentials, Region}; use aws_smithy_client::test_connection::capture_request; @@ -10,7 +11,6 @@ use aws_types::SdkConfig; use http::HeaderValue; use std::{ convert::Infallible, - sync::Arc, time::{Duration, UNIX_EPOCH}, }; @@ -54,7 +54,7 @@ const NAUGHTY_STRINGS: &str = include_str!("blns/blns.txt"); async fn test_s3_signer_with_naughty_string_metadata() { let (conn, rcvr) = capture_request(None); let sdk_config = SdkConfig::builder() - .credentials_provider(Arc::new(Credentials::for_tests())) + .credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests())) .region(Region::new("us-east-1")) .http_connector(conn.clone()) .build(); diff --git a/aws/sdk/integration-tests/s3/tests/normalize-uri-path.rs b/aws/sdk/integration-tests/s3/tests/normalize-uri-path.rs index c4e73812fc..d039064cbc 100644 --- a/aws/sdk/integration-tests/s3/tests/normalize-uri-path.rs +++ b/aws/sdk/integration-tests/s3/tests/normalize-uri-path.rs @@ -4,19 +4,19 @@ */ use aws_config::SdkConfig; +use aws_credential_types::provider::SharedCredentialsProvider; use aws_http::user_agent::AwsUserAgent; use aws_sdk_s3::types::ByteStream; use aws_sdk_s3::{Client, Credentials, Region}; use aws_smithy_client::test_connection::capture_request; use std::convert::Infallible; -use std::sync::Arc; use std::time::{Duration, UNIX_EPOCH}; #[tokio::test] async fn test_operation_should_not_normalize_uri_path() { let (conn, rx) = capture_request(None); let sdk_config = SdkConfig::builder() - .credentials_provider(Arc::new(Credentials::for_tests())) + .credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests())) .region(Region::new("us-east-1")) .http_connector(conn.clone()) .build(); diff --git a/aws/sdk/integration-tests/s3/tests/query-strings-are-correctly-encoded.rs b/aws/sdk/integration-tests/s3/tests/query-strings-are-correctly-encoded.rs index 381d55544d..858d013841 100644 --- a/aws/sdk/integration-tests/s3/tests/query-strings-are-correctly-encoded.rs +++ b/aws/sdk/integration-tests/s3/tests/query-strings-are-correctly-encoded.rs @@ -4,18 +4,18 @@ */ use aws_config::SdkConfig; +use aws_credential_types::provider::SharedCredentialsProvider; use aws_http::user_agent::AwsUserAgent; use aws_sdk_s3::{Client, Credentials, Region}; use aws_smithy_client::test_connection::capture_request; use std::convert::Infallible; -use std::sync::Arc; use std::time::{Duration, UNIX_EPOCH}; #[tokio::test] async fn test_s3_signer_query_string_with_all_valid_chars() { let (conn, rcvr) = capture_request(None); let sdk_config = SdkConfig::builder() - .credentials_provider(Arc::new(Credentials::for_tests())) + .credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests())) .region(Region::new("us-east-1")) .http_connector(conn.clone()) .build(); diff --git a/aws/sdk/integration-tests/s3/tests/recursion-detection.rs b/aws/sdk/integration-tests/s3/tests/recursion-detection.rs index fb3486444b..c4d7394475 100644 --- a/aws/sdk/integration-tests/s3/tests/recursion-detection.rs +++ b/aws/sdk/integration-tests/s3/tests/recursion-detection.rs @@ -4,10 +4,10 @@ */ use aws_config::SdkConfig; +use aws_credential_types::provider::SharedCredentialsProvider; use aws_sdk_s3::{Client, Credentials, Region}; use aws_smithy_client::test_connection::capture_request; use http::HeaderValue; -use std::sync::Arc; #[tokio::test] async fn recursion_detection_applied() { @@ -15,7 +15,7 @@ async fn recursion_detection_applied() { std::env::set_var("_X_AMZN_TRACE_ID", "traceid"); let (conn, captured_request) = capture_request(None); let sdk_config = SdkConfig::builder() - .credentials_provider(Arc::new(Credentials::for_tests())) + .credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests())) .region(Region::new("us-east-1")) .http_connector(conn.clone()) .build(); diff --git a/aws/sdk/integration-tests/s3/tests/select-object-content.rs b/aws/sdk/integration-tests/s3/tests/select-object-content.rs index ec22dfdb1f..d68af2f68b 100644 --- a/aws/sdk/integration-tests/s3/tests/select-object-content.rs +++ b/aws/sdk/integration-tests/s3/tests/select-object-content.rs @@ -4,6 +4,7 @@ */ use aws_config::SdkConfig; +use aws_credential_types::provider::SharedCredentialsProvider; use aws_sdk_s3::model::{ CompressionType, CsvInput, CsvOutput, ExpressionType, FileHeaderInfo, InputSerialization, OutputSerialization, SelectObjectContentEventStream, @@ -12,7 +13,6 @@ use aws_sdk_s3::{Client, Credentials, Region}; use aws_smithy_client::dvr::{Event, ReplayingConnection}; use aws_smithy_protocol_test::{assert_ok, validate_body, MediaType}; use std::error::Error; -use std::sync::Arc; #[tokio::test] async fn test_success() { @@ -21,7 +21,7 @@ async fn test_success() { let replayer = ReplayingConnection::new(events); let sdk_config = SdkConfig::builder() .region(Region::from_static("us-east-2")) - .credentials_provider(Arc::new(Credentials::for_tests())) + .credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests())) .http_connector(replayer.clone()) .build(); let client = Client::new(&sdk_config); diff --git a/aws/sdk/integration-tests/s3/tests/signing-it.rs b/aws/sdk/integration-tests/s3/tests/signing-it.rs index d9b2e56a14..0efdc9a5f6 100644 --- a/aws/sdk/integration-tests/s3/tests/signing-it.rs +++ b/aws/sdk/integration-tests/s3/tests/signing-it.rs @@ -4,12 +4,12 @@ */ use aws_config::SdkConfig; +use aws_credential_types::provider::SharedCredentialsProvider; use aws_http::user_agent::AwsUserAgent; use aws_sdk_s3::{Client, Credentials, Region}; use aws_smithy_client::test_connection::TestConnection; use aws_smithy_http::body::SdkBody; use std::convert::Infallible; -use std::sync::Arc; use std::time::{Duration, UNIX_EPOCH}; #[tokio::test] @@ -23,7 +23,7 @@ async fn test_signer() { http::Response::builder().status(200).body("").unwrap(), )]); let sdk_config = SdkConfig::builder() - .credentials_provider(Arc::new(Credentials::for_tests())) + .credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests())) .region(Region::new("us-east-1")) .http_connector(conn.clone()) .build(); diff --git a/aws/sdk/integration-tests/s3/tests/streaming-response.rs b/aws/sdk/integration-tests/s3/tests/streaming-response.rs index a437a755c8..8ff6d6eb37 100644 --- a/aws/sdk/integration-tests/s3/tests/streaming-response.rs +++ b/aws/sdk/integration-tests/s3/tests/streaming-response.rs @@ -4,12 +4,12 @@ */ use aws_config::SdkConfig; +use aws_credential_types::provider::SharedCredentialsProvider; use aws_sdk_s3::{Client, Credentials, Region}; use aws_smithy_types::error::display::DisplayErrorContext; use bytes::BytesMut; use std::future::Future; use std::net::SocketAddr; -use std::sync::Arc; use std::time::Duration; use tracing::debug; @@ -22,7 +22,7 @@ async fn test_streaming_response_fails_when_eof_comes_before_content_length_reac let _ = tokio::spawn(server); let sdk_config = SdkConfig::builder() - .credentials_provider(Arc::new(Credentials::for_tests())) + .credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests())) .region(Region::new("us-east-1")) .endpoint_url(format!("http://{server_addr}")) .build(); diff --git a/aws/sdk/integration-tests/s3/tests/timeouts.rs b/aws/sdk/integration-tests/s3/tests/timeouts.rs index 83da5c0860..5d1cacc5aa 100644 --- a/aws/sdk/integration-tests/s3/tests/timeouts.rs +++ b/aws/sdk/integration-tests/s3/tests/timeouts.rs @@ -4,6 +4,7 @@ */ use aws_config::SdkConfig; +use aws_credential_types::provider::SharedCredentialsProvider; use aws_sdk_s3::model::{ CompressionType, CsvInput, CsvOutput, ExpressionType, FileHeaderInfo, InputSerialization, OutputSerialization, @@ -25,7 +26,7 @@ use tokio::time::timeout; async fn test_timeout_service_ends_request_that_never_completes() { let sdk_config = SdkConfig::builder() .region(Region::from_static("us-east-2")) - .credentials_provider(Arc::new(Credentials::for_tests())) + .credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests())) .http_connector(NeverConnector::new()) .timeout_config( TimeoutConfig::builder() @@ -102,7 +103,7 @@ async fn test_read_timeout() { ) .endpoint_url(format!("http://{server_addr}")) .region(Some(Region::from_static("us-east-1"))) - .credentials_provider(Arc::new(Credentials::for_tests())) + .credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests())) .build(); let client = Client::new(&config); @@ -145,7 +146,7 @@ async fn test_connect_timeout() { "http://172.255.255.0:18104", ) .region(Some(Region::from_static("us-east-1"))) - .credentials_provider(Arc::new(Credentials::for_tests())) + .credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests())) .build(); let client = Client::new(&config); diff --git a/aws/sdk/integration-tests/s3/tests/user-agent-app-name.rs b/aws/sdk/integration-tests/s3/tests/user-agent-app-name.rs index f8947b3d83..8d72c52878 100644 --- a/aws/sdk/integration-tests/s3/tests/user-agent-app-name.rs +++ b/aws/sdk/integration-tests/s3/tests/user-agent-app-name.rs @@ -4,15 +4,15 @@ */ use aws_config::SdkConfig; +use aws_credential_types::provider::SharedCredentialsProvider; use aws_sdk_s3::{AppName, Client, Credentials, Region}; use aws_smithy_client::test_connection::capture_request; -use std::sync::Arc; #[tokio::test] async fn user_agent_app_name() { let (conn, rcvr) = capture_request(None); let sdk_config = SdkConfig::builder() - .credentials_provider(Arc::new(Credentials::for_tests())) + .credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests())) .region(Region::new("us-east-1")) .http_connector(conn.clone()) .app_name(AppName::new("test-app-name").expect("valid app name")) // set app name in config diff --git a/aws/sdk/integration-tests/s3control/tests/signing-it.rs b/aws/sdk/integration-tests/s3control/tests/signing-it.rs index 0aa31bb8f4..4a9857b17a 100644 --- a/aws/sdk/integration-tests/s3control/tests/signing-it.rs +++ b/aws/sdk/integration-tests/s3control/tests/signing-it.rs @@ -3,13 +3,13 @@ * SPDX-License-Identifier: Apache-2.0 */ +use aws_credential_types::provider::SharedCredentialsProvider; use aws_http::user_agent::AwsUserAgent; use aws_sdk_s3control::{Client, Credentials, Region}; use aws_smithy_client::test_connection::TestConnection; use aws_smithy_http::body::SdkBody; use aws_types::SdkConfig; use std::convert::Infallible; -use std::sync::Arc; use std::time::{Duration, UNIX_EPOCH}; #[tokio::test] @@ -26,7 +26,7 @@ async fn test_signer() { http::Response::builder().status(200).body("").unwrap(), )]); let sdk_config = SdkConfig::builder() - .credentials_provider(Arc::new(Credentials::for_tests())) + .credentials_provider(SharedCredentialsProvider::new(Credentials::for_tests())) .http_connector(conn.clone()) .region(Region::new("us-east-1")) .build();