Struct aws_config::meta::credentials::CredentialsProviderChain
source · pub struct CredentialsProviderChain { /* private fields */ }
Expand description
Credentials provider that checks a series of inner providers
Each provider will be evaluated in order:
- If a provider returns valid
Credentials
they will be returned immediately. No other credential providers will be used. - Otherwise, if a provider returns
CredentialsError::CredentialsNotLoaded
, the next provider will be checked. - Finally, if a provider returns any other error condition, an error will be returned immediately.
Examples
use aws_config::meta::credentials::CredentialsProviderChain;
use aws_config::environment::credentials::EnvironmentVariableCredentialsProvider;
use aws_config::profile::ProfileFileCredentialsProvider;
let provider = CredentialsProviderChain::first_try("Environment", EnvironmentVariableCredentialsProvider::new())
.or_else("Profile", ProfileFileCredentialsProvider::builder().build());
Implementations§
source§impl CredentialsProviderChain
impl CredentialsProviderChain
sourcepub fn first_try(
name: impl Into<Cow<'static, str>>,
provider: impl ProvideCredentials + 'static
) -> Self
pub fn first_try( name: impl Into<Cow<'static, str>>, provider: impl ProvideCredentials + 'static ) -> Self
Create a CredentialsProviderChain
that begins by evaluating this provider
sourcepub fn or_else(
self,
name: impl Into<Cow<'static, str>>,
provider: impl ProvideCredentials + 'static
) -> Self
pub fn or_else( self, name: impl Into<Cow<'static, str>>, provider: impl ProvideCredentials + 'static ) -> Self
Add a fallback provider to the credentials provider chain
sourcepub async fn or_default_provider(self) -> Self
pub async fn or_default_provider(self) -> Self
Add a fallback to the default provider chain
sourcepub async fn default_provider() -> Self
pub async fn default_provider() -> Self
Creates a credential provider chain that starts with the default provider
Trait Implementations§
source§impl Debug for CredentialsProviderChain
impl Debug for CredentialsProviderChain
source§impl ProvideCredentials for CredentialsProviderChain
impl ProvideCredentials for CredentialsProviderChain
source§fn provide_credentials<'a>(&'a self) -> ProvideCredentials<'_>where
Self: 'a,
fn provide_credentials<'a>(&'a self) -> ProvideCredentials<'_>where Self: 'a,
Returns a future that provides credentials.