DEV Community

Cover image for Did You Know? IAM precedence
Rola Dali
Rola Dali

Posted on

Did You Know? IAM precedence

Do you have several AWS credentials and are confused which one is being used?

AWS has a defined Default Credential Provider Chain which dictates the order of which credentials it uses in the case where there are several.

The Default Credential Provider Chain Order for Java SDK is:

  1. Environment variables: "AWS_ACCESS_KEY_ID" and "AWS_SECRET_ACCESS_KEY".
  2. Java system properties: aws.accessKeyId and aws.secretAccessKey.
  3. Web Identity Token credentials from the environment or container.
  4. The default credential profiles file: typically located at ~/.aws/credentials
  5. Amazon ECS container credentials: loaded from the Amazon ECS if the environment variable AWS_\CONTAINER_CREDENTIALS_RELATIVE_URI is set.
  6. Instance profile credentials: used on EC2 instances, and delivered through the Amazon EC2 metadata service.

Reference

Now You Know!

Top comments (0)