When I try to access my Amazon Simple Storage Service (Amazon S3) bucket using the AWS Command Line Interface (AWS CLI), I get the error "Unable to locate credentials." How can I fix this?
The AWS CLI returns this error when it can't locate the credentials to authenticate AWS API calls. You must be sure that your AWS credentials are correctly configured in the AWS CLI.
To check if the AWS CLI is configured with credentials, run this command:
$ aws configure list
If your credentials are configured in the config file, the command returns a response similar to the following:
Name Value Type Location
---- ----- ---- --------
profile <not set> None None
access_key ****************ABCD config_file ~/.aws/config
secret_key ****************ABCD config_file ~/.aws/config
region us-west-2 env AWS_DEFAULT_REGION
If your credentials are configured in an instance profile, the command returns a response similar to the following:
Name Value Type Location
---- ----- ---- --------
profile <not set> None None
access_key ****************YVEQ iam-role
secret_key ****************2a9N iam-role
region <not set> None None
Review the response to check whether credentials are missing or the stored credentials are incorrect. If so, update your credentials.
Note: The AWS CLI invokes credential providers in a specific order, and the AWS CLI stops invoking providers when it finds a set of credentials to use. This means that if you have credentials configured incorrectly on a credential provider with higher precedence, you get the "Unable to locate credentials" error. You get this error even if credentials are configured correctly on a provider with lower precedence.
After you update your credentials, test the AWS CLI by running an Amazon S3 AWS CLI command, such as aws s3 ls.
Did this page help you? Yes | No
Back to the AWS Support Knowledge Center
Need help? Visit the AWS Support Center
Published: 2019-01-07