Configuring Amazon SDK for Rust service clients externally - Amazon SDK for Rust
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Configuring Amazon SDK for Rust service clients externally

Many configuration settings can be handled outside of your code. When configuration is handled externally, the configuration is applied across all of your applications. Most configuration settings can be set as either environment variables or in a separate shared Amazon config file. The shared config file can maintain separate sets of settings, called profiles, to provide different configurations for different environments or tests.

Environment variables and shared config file settings are standardized and shared across Amazon SDKs and tools to support consistent functionality across different programming languages and applications.

See the Amazon SDKs and Tools Reference Guide to learn about configuring your application through these methods, plus details on each cross-sdk setting. To see all the all settings that the SDK can resolve from the environment variables or configuration files, see the Settings reference in the Amazon SDKs and Tools Reference Guide.

To make a request to an Amazon Web Services service, you first instantiate a client for that service. You can configure common settings for service clients such as timeouts, the HTTP client, and retry configuration.

Each service client requires an Amazon Web Services Region and a credential provider. The SDK uses these values to send requests to the correct Region for your resources and to sign requests with the correct credentials. You can specify these values programmatically in code or have them automatically loaded from the environment.

The SDK has a series of places (or sources) that it checks in order to find a value for configuration settings.

  1. Any explicit setting set in the code or on a service client itself takes precedence over anything else.

  2. Environment variables

    • For details on setting environment variables, see environment variables in the Amazon SDKs and Tools Reference Guide.

    • Note that you can configure environment variables for a shell at different levels of scope: system-wide, user-wide, and for a specific terminal session.

  3. Shared config and credentials files

  4. Any default value provided by the SDK source code itself is used last.

    • Some properties, such as Region, don't have a default. You must specify them either explicitly in code, in an environment setting, or in the shared config file. If the SDK can't resolve required configuration, API requests can fail at runtime.