A credential provider chain is a credential-discovery mechanism implemented by an SDK, command-line tool, or authentication library. Each provider knows how to obtain credentials from a particular source, such as environment variables, a configuration profile, an external process, or a workload identity endpoint. The chain evaluates providers in a defined order and normally stops when a provider successfully returns credentials. This keeps credential acquisition separate from application logic and allows applications to move between environments without embedding secrets in source code.
For AWS programmatic access, common sources include environment variables, shared configuration and credentials files, role-assumption configurations, web identity tokens, container credential endpoints, and Amazon EC2 instance metadata. Some SDKs also support IAM Identity Center profiles and external credential processes. There is no single precedence order that applies identically to every AWS SDK, SDK version, and the AWS CLI. Check the documentation for the exact tool in use. Explicit credentials supplied to a client generally bypass its default discovery chain, while explicitly selecting a provider or profile can change how credentials are resolved.
During local development, an engineer might configure an IAM Identity Center profile, sign in with the AWS CLI, and select that profile through supported SDK configuration. The SDK obtains temporary credentials associated with the selected role. When the application runs on EC2, it can instead obtain temporary credentials for an IAM role attached through an instance profile. On Amazon ECS, application credentials come from the task role through the container credential provider. These approaches avoid distributing long-lived IAM user access keys to application hosts.
Temporary AWS credentials contain an access key ID, a secret access key, and a session token. All three are required when those credentials are supplied manually. Supported SDK credential providers can cache credentials and refresh them before expiration, provided the underlying session or identity remains usable. Copying temporary credentials into environment variables creates a static credential snapshot; it does not provide the refresh behavior of the original role or identity provider.
Precedence creates an important operational trade-off: convenient automatic discovery can hide the identity an application actually uses. For example, access keys left in environment variables may override the intended instance role. If those keys are expired, or identify a principal without the necessary permissions, requests can fail despite the workload having a correctly configured role. Use AWS STS GetCallerIdentity with the same credential configuration as the application to inspect the effective identity, and remove unintended credential sources rather than granting broader permissions.
A provider chain is not an authorization fallback mechanism. Once credentials have been selected, an AccessDenied response does not normally cause the SDK to retry the request using the next identity. Missing-source and provider-error behavior also varies by implementation; malformed or incomplete credentials can terminate resolution rather than being silently skipped. Finally, selecting credentials does not grant permissions, configure a role trust policy, or necessarily select a Region. Production designs should combine workload roles, least-privilege permissions, protected credential endpoints, automatic refresh, and diagnostics that never log secret keys or session tokens.