Struct aws_config::ConfigLoader
source · [−]pub struct ConfigLoader { /* private fields */ }
Expand description
Load a cross-service SdkConfig
from the environment
This builder supports overriding individual components of the generated config. Overriding a component will skip the standard resolution chain from for that component. For example, if you override the region provider, even if that provider returns None, the default region provider chain will not be used.
Implementations
sourceimpl ConfigLoader
impl ConfigLoader
sourcepub fn region(self, region: impl ProvideRegion + 'static) -> Self
pub fn region(self, region: impl ProvideRegion + 'static) -> Self
sourcepub fn retry_config(self, retry_config: RetryConfig) -> Self
pub fn retry_config(self, retry_config: RetryConfig) -> Self
sourcepub fn timeout_config(self, timeout_config: TimeoutConfig) -> Self
pub fn timeout_config(self, timeout_config: TimeoutConfig) -> Self
Override the timeout config used to build SdkConfig
.
Note: This only sets timeouts for calls to AWS services. Timeouts for the credentials
provider chain are configured separately.
Examples
use aws_smithy_types::timeout::TimeoutConfig;
let config = aws_config::from_env()
.timeout_config(
TimeoutConfig::builder()
.operation_timeout(Duration::from_secs(5))
.build()
)
.load()
.await;
sourcepub fn sleep_impl(self, sleep: impl AsyncSleep + 'static) -> Self
pub fn sleep_impl(self, sleep: impl AsyncSleep + 'static) -> Self
Override the sleep implementation for this ConfigLoader
. The sleep implementation
is used to create timeout futures.
sourcepub fn http_connector(self, http_connector: HttpConnector) -> Self
pub fn http_connector(self, http_connector: HttpConnector) -> Self
Override the HttpConnector
used to build SdkConfig
.
sourcepub fn credentials_provider(
self,
credentials_provider: impl ProvideCredentials + 'static
) -> Self
pub fn credentials_provider(
self,
credentials_provider: impl ProvideCredentials + 'static
) -> Self
sourcepub fn endpoint_resolver(
self,
endpoint_resolver: impl ResolveAwsEndpoint + 'static
) -> Self
pub fn endpoint_resolver(
self,
endpoint_resolver: impl ResolveAwsEndpoint + 'static
) -> Self
Override the endpoint resolver used for all AWS Services
This method will override the endpoint resolver used for all AWS services. This mainly
exists to set a static endpoint for tools like LocalStack
. For live traffic, AWS services
require the service-specific endpoint resolver they load by default.
Examples
Use a static endpoint for all services
use aws_smithy_http::endpoint::Endpoint;
let sdk_config = aws_config::from_env()
.endpoint_resolver(Endpoint::immutable("http://localhost:1234".parse().expect("valid URI")))
.load().await;
sourcepub fn configure(self, provider_config: ProviderConfig) -> Self
pub fn configure(self, provider_config: ProviderConfig) -> Self
Set configuration for all sub-loaders (credentials, region etc.)
Update the ProviderConfig
used for all nested loaders. This can be used to override
the HTTPs connector used or to stub in an in memory Env
or Fs
for testing.
Examples
use aws_config::provider_config::ProviderConfig;
let custom_https_connector = hyper_rustls::HttpsConnectorBuilder::new().
with_webpki_roots()
.https_only()
.enable_http1()
.build();
let provider_config = ProviderConfig::default().with_tcp_connector(custom_https_connector);
let shared_config = aws_config::from_env().configure(provider_config).load().await;
sourcepub async fn load(self) -> SdkConfig
pub async fn load(self) -> SdkConfig
Load the default configuration chain
If fields have been overridden during builder construction, the override values will be used.
Otherwise, the default values for each field will be provided.
NOTE: When an override is provided, the default implementation is not used as a fallback.
This means that if you provide a region provider that does not return a region, no region will
be set in the resulting SdkConfig