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

Override the region used to build SdkConfig.

Examples
use aws_types::region::Region;
let config = aws_config::from_env()
    .region(Region::new("us-east-1"))
    .load().await;

Override the retry_config used to build SdkConfig.

Examples
    let config = aws_config::from_env()
        .retry_config(RetryConfig::new().with_max_attempts(2))
        .load().await;

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, tristate::TriState};

 let api_timeout_config = timeout::Api::new()
    .with_call_timeout(TriState::Set(Duration::from_secs(1)));
 let timeout_config = timeout::Config::new().with_api_timeouts(api_timeout_config);
 let config = aws_config::from_env()
    .timeout_config(timeout_config)
    .load()
    .await;

Override the sleep implementation for this ConfigLoader. The sleep implementation is used to create timeout futures.

Override the HttpConnector used to build SdkConfig.

Override the credentials provider used to build SdkConfig.

Examples

Override the credentials provider but load the default value for region:

let config = aws_config::from_env()
    .credentials_provider(create_my_credential_provider())
    .load()
    .await;

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;

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;

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

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more