Hosting » AWS » Where does AWS CLI look for credentials?

Where does AWS CLI look for credentials?

Last updated on December 16, 2022 @ 12:25 pm

AWS CLI looks for credentials in the following places:

1. Session profile file (.profile) in the home directory of the user invoking the CLI.

2. The default credential file (.AWS/credentials) located in the home directory of the user’s user profile.

3. The .AWS/credentials file in the current working directory.

AWS/credentials file in the root of the current AWS account.

PRO TIP: The AWS CLI looks for credentials in a number of places, including environment variables, the AWS credentials file, and the EC2 Instance Metadata service. If you use the AWS CLI to access AWS resources, you should be aware of the potential security implications.

5. The ~/.AWS/credentials file.

The session profile file (.profile) is the default credential file. If the session profile file is not found, AWS CLI looks for the AWS/credentials file in the home directory of the user invoking the CLI and the current working directory.

If the .AWS/credentials file is not found in either location, AWS CLI looks for the .AWS/credentials file in the root of the current AWS account.

If the .AWS/credentials file is not found in any of the locations specified, AWS CLI prompts for credentials.

Drew Clemente

Drew Clemente

Devops & Sysadmin engineer. I basically build infrastructure online.