Example
// AWS access credentials: access key, secret key, and optional token.
# Example
// Loads from the standard AWS credentials file with the given profile name,
// defaults to "default".
use Credentials;
// Load credentials from `[default]` profile
let credentials = default;
// Also loads credentials from `[default]` profile
let credentials = new;
// Load credentials from `[my-profile]` profile
let credentials = new;
// Credentials may also be initialized directly or by the following environment variables:
// - `AWS_ACCESS_KEY_ID`,
// - `AWS_SECRET_ACCESS_KEY`
// - `AWS_SESSION_TOKEN`
// The order of preference is arguments, then environment, and finally AWS
// credentials file.
use Credentials;
// Load credentials directly
let access_key = Stringfrom;
let secret_key = Stringfrom;
let credentials = new;
// Load credentials from the environment
use env;
set_var;
set_var;
let credentials = new;
Container credentials
With the http-credentials feature enabled, Credentials::from_container_credentials_provider
uses AWS_CONTAINER_CREDENTIALS_RELATIVE_URI before
AWS_CONTAINER_CREDENTIALS_FULL_URI. For full URIs, token files take precedence
over AWS_CONTAINER_AUTHORIZATION_TOKEN, and token files are reread during
refresh. HTTPS accepts normal hosts. HTTP is intentionally narrower than the
AWS SDK policy: only literal loopback, localhost, and the documented ECS/EKS
link-local addresses are accepted. HTTP metadata requests bypass environment
proxies; HTTPS may use the configured proxy. localhost is normalized to
127.0.0.1, and redirects are not followed. The HTTP hostname restriction is
narrower than AWS SDK behavior by design.