Understand the default credential provider chain - Amazon SDK for PHP
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).

Understand the default credential provider chain

The default credential provider chain is made up of a series of built-in credential providers that the SDK invokes. It is implemented by the defaultProvider credential provider function with no parameters. After valid credentials are found, the search is stopped.

The Amazon SDK for PHP executes credential providers in the following order:

  • ecsCredentials provider - The SDK looks for the environment variables AWS_CONTAINER_CREDENTIALS_RELATIVE_URI or AWS_CONTAINER_CREDENTIALS_FULL_URI that provide information to acquire temporary credentials.

  • instanceProfile provider - The SDK uses the EC2 Instance Metadata service to get the IAM role specified in the instance profile. Using the role information, the SDK acquires temporary credentials.

Note

The result of the default provider is automatically memoized.

You can review the code for the chain in the GitHub source code.