Aws-cli: Unable to locate credentials

Created on 19 Sep 2014  ·  18Comments  ·  Source: aws/aws-cli

I can successfully use the awscli when specifying the environment variables: AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, however in previous installs of awscli:

  • Configuration would automatically read from the configuration file in ~/.aws/config - which is not currently working for me

Also, specifying the AWS_CONFIG_FILE does not work either

Was able to reproduce on an AWS EC2 instance and locally on Vagrant box

~$ aws --version
aws-cli/1.4.4 Python/2.7.6 Linux/3.13.0-29-generic

~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04 LTS
Release:    14.04
Codename:   trusty

Failing examples:

aws s3 cp test.txt s3://my-bucket/
# => upload failed: ./test.txt to s3://my-bucket/test.txt Unable to locate credentials

AWS_CONFIG_FILE=/home/ubuntu/.aws/config aws s3 cp test.txt s3://my-bucket/ 
# => upload failed: ./test.txt to s3://my-bucket/test.txt Unable to locate credentials

Successful examples:

AWS_ACCESS_KEY_ID=xxxx AWS_SECRET_ACCESS_KEY=xxxx aws s3 cp test.txt s3://my-bucket/ 
# ^ this works

Debug flag on:

aws --debug s3 cp test.txt s3://my-bucket/
2014-09-19 18:29:08,076 - MainThread - awscli.clidriver - DEBUG - CLI version: aws-cli/1.4.4 Python/2.7.6 Linux/3.13.0-29-generic, botocore version: 0.63.0
2014-09-19 18:29:08,076 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.s3.anonymous: calling handler <function uri_param at 0x7f12296d7aa0>
2014-09-19 18:29:08,078 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.cp.paths: calling handler <function uri_param at 0x7f12296d7aa0>
2014-09-19 18:29:08,078 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.cp.cache-control: calling handler <function uri_param at 0x7f12296d7aa0>
2014-09-19 18:29:08,078 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.cp.dryrun: calling handler <function uri_param at 0x7f12296d7aa0>
2014-09-19 18:29:08,079 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.cp.website-redirect: calling handler <function uri_param at 0x7f12296d7aa0>
2014-09-19 18:29:08,079 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.cp.grants: calling handler <function uri_param at 0x7f12296d7aa0>
2014-09-19 18:29:08,079 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.cp.expires: calling handler <function uri_param at 0x7f12296d7aa0>
2014-09-19 18:29:08,079 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.cp.quiet: calling handler <function uri_param at 0x7f12296d7aa0>
2014-09-19 18:29:08,079 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.cp.anonymous: calling handler <function uri_param at 0x7f12296d7aa0>
2014-09-19 18:29:08,079 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.cp.acl: calling handler <function uri_param at 0x7f12296d7aa0>
2014-09-19 18:29:08,079 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.cp.source-region: calling handler <function uri_param at 0x7f12296d7aa0>
2014-09-19 18:29:08,079 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.cp.anonymous: calling handler <function uri_param at 0x7f12296d7aa0>
2014-09-19 18:29:08,080 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.cp.content-type: calling handler <function uri_param at 0x7f12296d7aa0>
2014-09-19 18:29:08,080 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.cp.content-encoding: calling handler <function uri_param at 0x7f12296d7aa0>
2014-09-19 18:29:08,080 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.cp.anonymous: calling handler <function uri_param at 0x7f12296d7aa0>
2014-09-19 18:29:08,080 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.cp.storage-class: calling handler <function uri_param at 0x7f12296d7aa0>
2014-09-19 18:29:08,080 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.cp.sse: calling handler <function uri_param at 0x7f12296d7aa0>
2014-09-19 18:29:08,080 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.cp.content-language: calling handler <function uri_param at 0x7f12296d7aa0>
2014-09-19 18:29:08,080 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.cp.content-disposition: calling handler <function uri_param at 0x7f12296d7aa0>
2014-09-19 18:29:08,080 - MainThread - botocore.hooks - DEBUG - Event load-cli-arg.custom.cp.follow-symlinks: calling handler <function uri_param at 0x7f12296d7aa0>
2014-09-19 18:29:08,080 - MainThread - botocore.service - DEBUG - Creating service object for: s3
2014-09-19 18:29:08,105 - MainThread - botocore.hooks - DEBUG - Event service-data-loaded.s3: calling handler <function signature_overrides at 0x7f1229924de8>
2014-09-19 18:29:08,105 - MainThread - botocore.hooks - DEBUG - Event service-created: calling handler <function register_retries_for_service at 0x7f1229924c08>
2014-09-19 18:29:08,106 - MainThread - botocore.handlers - DEBUG - Registering retry handlers for service: Service(s3)
2014-09-19 18:29:08,107 - MainThread - botocore.hooks - DEBUG - Event creating-endpoint.s3: calling handler <function maybe_switch_to_s3sigv4 at 0x7f1229924cf8>
2014-09-19 18:29:08,107 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: env
2014-09-19 18:29:08,107 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: shared-credentials-file
2014-09-19 18:29:08,107 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: config-file
2014-09-19 18:29:08,107 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: ec2-credentials-file
2014-09-19 18:29:08,108 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: boto-config
2014-09-19 18:29:08,108 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: iam-role
2014-09-19 18:29:08,114 - MainThread - botocore.vendored.requests.packages.urllib3.connectionpool - INFO - Starting new HTTP connection (1): 169.254.169.254
2014-09-19 18:29:08,115 - MainThread - botocore.vendored.requests.packages.urllib3.connectionpool - DEBUG - "GET /latest/meta-data/iam/security-credentials/ HTTP/1.1" 404 345
2014-09-19 18:29:08,115 - MainThread - botocore.utils - DEBUG - Max number of attempts exceeded (1) when attempting to retrieve data from metadata service.
2014-09-19 18:29:08,115 - MainThread - botocore.service - DEBUG - Creating service object for: s3
2014-09-19 18:29:08,115 - MainThread - botocore.hooks - DEBUG - Event service-data-loaded.s3: calling handler <function signature_overrides at 0x7f1229924de8>
2014-09-19 18:29:08,116 - MainThread - botocore.hooks - DEBUG - Event service-created: calling handler <function register_retries_for_service at 0x7f1229924c08>
2014-09-19 18:29:08,116 - MainThread - botocore.handlers - DEBUG - Registering retry handlers for service: Service(s3)
2014-09-19 18:29:08,116 - MainThread - botocore.hooks - DEBUG - Event creating-endpoint.s3: calling handler <function maybe_switch_to_s3sigv4 at 0x7f1229924cf8>
2014-09-19 18:29:08,116 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: env
2014-09-19 18:29:08,116 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: shared-credentials-file
2014-09-19 18:29:08,116 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: config-file
2014-09-19 18:29:08,117 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: ec2-credentials-file
2014-09-19 18:29:08,117 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: boto-config
2014-09-19 18:29:08,117 - MainThread - botocore.credentials - DEBUG - Looking for credentials via: iam-role
2014-09-19 18:29:08,118 - MainThread - botocore.vendored.requests.packages.urllib3.connectionpool - INFO - Starting new HTTP connection (1): 169.254.169.254
2014-09-19 18:29:08,118 - MainThread - botocore.vendored.requests.packages.urllib3.connectionpool - DEBUG - "GET /latest/meta-data/iam/security-credentials/ HTTP/1.1" 404 345
2014-09-19 18:29:08,119 - MainThread - botocore.utils - DEBUG - Max number of attempts exceeded (1) when attempting to retrieve data from metadata service.
2014-09-19 18:29:08,122 - MainThread - botocore.service - DEBUG - Creating service object for: s3
2014-09-19 18:29:08,122 - MainThread - botocore.hooks - DEBUG - Event service-data-loaded.s3: calling handler <function signature_overrides at 0x7f1229924de8>
2014-09-19 18:29:08,122 - MainThread - botocore.hooks - DEBUG - Event service-created: calling handler <function register_retries_for_service at 0x7f1229924c08>
2014-09-19 18:29:08,123 - MainThread - botocore.handlers - DEBUG - Registering retry handlers for service: Service(s3)
2014-09-19 18:29:08,123 - MainThread - awscli.customizations.s3.executor - DEBUG - Submitting task: <awscli.customizations.s3.tasks.BasicTask object at 0x7f122808a210>
2014-09-19 18:29:08,123 - MainThread - awscli.customizations.s3.executor - DEBUG - Queueing end sentinel for worker thread (priority: 11)
2014-09-19 18:29:08,123 - Thread-3 - awscli.customizations.s3.executor - DEBUG - Worker thread invoking task: <awscli.customizations.s3.tasks.BasicTask object at 0x7f122808a210>
2014-09-19 18:29:08,123 - MainThread - awscli.customizations.s3.executor - DEBUG - Queueing end sentinel for worker thread (priority: 11)
2014-09-19 18:29:08,123 - Thread-4 - awscli.customizations.s3.executor - DEBUG - Shutdown request received in worker thread, shutting down worker thread.
2014-09-19 18:29:08,124 - MainThread - awscli.customizations.s3.executor - DEBUG - Queueing end sentinel for worker thread (priority: 11)
2014-09-19 18:29:08,124 - Thread-5 - awscli.customizations.s3.executor - DEBUG - Shutdown request received in worker thread, shutting down worker thread.
2014-09-19 18:29:08,126 - MainThread - awscli.customizations.s3.executor - DEBUG - Queueing end sentinel for worker thread (priority: 11)
2014-09-19 18:29:08,126 - Thread-6 - awscli.customizations.s3.executor - DEBUG - Shutdown request received in worker thread, shutting down worker thread.
2014-09-19 18:29:08,126 - MainThread - awscli.customizations.s3.executor - DEBUG - Queueing end sentinel for worker thread (priority: 11)
2014-09-19 18:29:08,126 - Thread-7 - awscli.customizations.s3.executor - DEBUG - Shutdown request received in worker thread, shutting down worker thread.
2014-09-19 18:29:08,129 - Thread-3 - botocore.service - DEBUG - Creating operation objects for: Service(s3)
2014-09-19 18:29:08,127 - MainThread - awscli.customizations.s3.executor - DEBUG - Queueing end sentinel for worker thread (priority: 11)
2014-09-19 18:29:08,134 - Thread-3 - botocore.operation - DEBUG - Operation:PutObject called with kwargs: {'body': <open file u'/home/ubuntu/test.txt', mode 'rb' at 0x7f12290d5270>, 'bucket': u'my-bucket', 'key': u'test.txt', 'content_type': 'text/plain'}
2014-09-19 18:29:08,127 - Thread-8 - awscli.customizations.s3.executor - DEBUG - Shutdown request received in worker thread, shutting down worker thread.
2014-09-19 18:29:08,135 - Thread-3 - botocore.operation - DEBUG - Creating parameter objects for: Operation:PutObject
2014-09-19 18:29:08,138 - Thread-3 - botocore.hooks - DEBUG - Event before-call.s3.PutObject: calling handler <function sse_md5 at 0x7f1229924a28>
2014-09-19 18:29:08,138 - Thread-3 - botocore.hooks - DEBUG - Event before-call.s3.PutObject: calling handler <function add_expect_header at 0x7f1229924e60>
2014-09-19 18:29:08,138 - Thread-3 - botocore.handlers - DEBUG - Adding expect 100 continue header to request.
2014-09-19 18:29:08,138 - Thread-3 - botocore.endpoint - DEBUG - Making request for Operation:PutObject (verify_ssl=True) with params: {'headers': {u'Content-Type': 'text/plain', 'Expect': '100-continue'}, 'uri_params': {u'Bucket': u'my-bucket', u'Key': u'test.txt'}, 'payload': <botocore.payload.Payload object at 0x7f12280ad0d0>}
2014-09-19 18:29:08,139 - Thread-3 - botocore.endpoint - DEBUG - Building URI for rest endpoint.
2014-09-19 18:29:08,139 - Thread-3 - botocore.endpoint - DEBUG - Templated URI path: /{Bucket}/{Key}
2014-09-19 18:29:08,139 - Thread-3 - botocore.endpoint - DEBUG - Templated URI query_params:
2014-09-19 18:29:08,135 - MainThread - awscli.customizations.s3.executor - DEBUG - Queueing end sentinel for worker thread (priority: 11)
2014-09-19 18:29:08,139 - Thread-3 - botocore.endpoint - DEBUG - Rendered path: /my-bucket/test.txt
2014-09-19 18:29:08,139 - Thread-3 - botocore.endpoint - DEBUG - Rendered query_params:
2014-09-19 18:29:08,140 - Thread-3 - botocore.hooks - DEBUG - Event before-auth.s3: calling handler <function fix_s3_host at 0x7f1229924b18>
2014-09-19 18:29:08,140 - Thread-3 - botocore.handlers - DEBUG - Checking for DNS compatible bucket for: https://s3.amazonaws.com/my-bucket/test.txt
2014-09-19 18:29:08,140 - Thread-3 - botocore.handlers - DEBUG - URI updated to: https://my-bucket.s3.amazonaws.com/test.txt
2014-09-19 18:29:08,135 - Thread-9 - awscli.customizations.s3.executor - DEBUG - Shutdown request received in worker thread, shutting down worker thread.
2014-09-19 18:29:08,140 - Thread-3 - awscli.customizations.s3.tasks - DEBUG - Unable to locate credentials
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/awscli/customizations/s3/tasks.py", line 89, in _execute_task
    getattr(filename, filename.operation_name)()
  File "/usr/local/lib/python2.7/dist-packages/awscli/customizations/s3/fileinfo.py", line 221, in upload
    response_data, http = operate(self.service, 'PutObject', params)
  File "/usr/local/lib/python2.7/dist-packages/awscli/customizations/s3/utils.py", line 193, in operate
    http_response, response_data = operation.call(**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/botocore/operation.py", line 68, in call
    response = endpoint.make_request(self, params)
  File "/usr/local/lib/python2.7/dist-packages/botocore/endpoint.py", line 68, in make_request
    prepared_request = self.create_request(operation, params)
  File "/usr/local/lib/python2.7/dist-packages/botocore/endpoint.py", line 92, in create_request
    prepared_request = self.prepare_request(request, signer)
  File "/usr/local/lib/python2.7/dist-packages/botocore/endpoint.py", line 108, in prepare_request
    signer.add_auth(request=request)
  File "/usr/local/lib/python2.7/dist-packages/botocore/auth.py", line 545, in add_auth
    raise NoCredentialsError
NoCredentialsError: Unable to locate credentials
2014-09-19 18:29:08,140 - MainThread - awscli.customizations.s3.executor - DEBUG - Queueing end sentinel for worker thread (priority: 11)
2014-09-19 18:29:08,140 - Thread-10 - awscli.customizations.s3.executor - DEBUG - Shutdown request received in worker thread, shutting down worker thread.
2014-09-19 18:29:08,141 - Thread-1 - awscli.customizations.s3.executor - DEBUG - Received print task: PrintTask(message=u'upload failed: ./test.txt to s3://my-bucket/test.txt Unable to locate credentials', error=True, total_parts=None, warning=None)
upload failed: ./test.txt to s3://my-bucket/test.txt Unable to locate credentials
2014-09-19 18:29:08,142 - Thread-11 - awscli.customizations.s3.executor - DEBUG - Shutdown request received in worker thread, shutting down worker thread.
2014-09-19 18:29:08,142 - MainThread - awscli.customizations.s3.executor - DEBUG - Queueing end sentinel for worker thread (priority: 11)
2014-09-19 18:29:08,142 - MainThread - awscli.customizations.s3.executor - DEBUG - Queueing end sentinel for worker thread (priority: 11)
2014-09-19 18:29:08,143 - Thread-12 - awscli.customizations.s3.executor - DEBUG - Shutdown request received in worker thread, shutting down worker thread.
2014-09-19 18:29:08,143 - MainThread - awscli.customizations.s3.executor - DEBUG - Waiting for thread to shutdown: <Worker(Thread-3, started daemon 139715890116352)>
2014-09-19 18:29:08,143 - Thread-3 - awscli.customizations.s3.executor - DEBUG - Shutdown request received in worker thread, shutting down worker thread.
2014-09-19 18:29:08,144 - MainThread - awscli.customizations.s3.executor - DEBUG - Thread has been shutdown: <Worker(Thread-3, stopped daemon 139715890116352)>
2014-09-19 18:29:08,144 - MainThread - awscli.customizations.s3.executor - DEBUG - Waiting for thread to shutdown: <Worker(Thread-4, stopped daemon 139715881723648)>
2014-09-19 18:29:08,144 - MainThread - awscli.customizations.s3.executor - DEBUG - Thread has been shutdown: <Worker(Thread-4, stopped daemon 139715881723648)>
2014-09-19 18:29:08,144 - MainThread - awscli.customizations.s3.executor - DEBUG - Waiting for thread to shutdown: <Worker(Thread-5, stopped daemon 139715873330944)>
2014-09-19 18:29:08,145 - MainThread - awscli.customizations.s3.executor - DEBUG - Thread has been shutdown: <Worker(Thread-5, stopped daemon 139715873330944)>
2014-09-19 18:29:08,145 - MainThread - awscli.customizations.s3.executor - DEBUG - Waiting for thread to shutdown: <Worker(Thread-6, stopped daemon 139715864938240)>
2014-09-19 18:29:08,145 - MainThread - awscli.customizations.s3.executor - DEBUG - Thread has been shutdown: <Worker(Thread-6, stopped daemon 139715864938240)>
2014-09-19 18:29:08,145 - MainThread - awscli.customizations.s3.executor - DEBUG - Waiting for thread to shutdown: <Worker(Thread-7, stopped daemon 139715856545536)>
2014-09-19 18:29:08,145 - MainThread - awscli.customizations.s3.executor - DEBUG - Thread has been shutdown: <Worker(Thread-7, stopped daemon 139715856545536)>
2014-09-19 18:29:08,145 - MainThread - awscli.customizations.s3.executor - DEBUG - Waiting for thread to shutdown: <Worker(Thread-8, stopped daemon 139715848152832)>
2014-09-19 18:29:08,145 - MainThread - awscli.customizations.s3.executor - DEBUG - Thread has been shutdown: <Worker(Thread-8, stopped daemon 139715848152832)>
2014-09-19 18:29:08,145 - MainThread - awscli.customizations.s3.executor - DEBUG - Waiting for thread to shutdown: <Worker(Thread-9, stopped daemon 139715839760128)>
2014-09-19 18:29:08,145 - MainThread - awscli.customizations.s3.executor - DEBUG - Thread has been shutdown: <Worker(Thread-9, stopped daemon 139715839760128)>
2014-09-19 18:29:08,145 - MainThread - awscli.customizations.s3.executor - DEBUG - Waiting for thread to shutdown: <Worker(Thread-10, stopped daemon 139715286136576)>
2014-09-19 18:29:08,145 - MainThread - awscli.customizations.s3.executor - DEBUG - Thread has been shutdown: <Worker(Thread-10, stopped daemon 139715286136576)>
2014-09-19 18:29:08,146 - MainThread - awscli.customizations.s3.executor - DEBUG - Waiting for thread to shutdown: <Worker(Thread-11, stopped daemon 139715277743872)>
2014-09-19 18:29:08,146 - MainThread - awscli.customizations.s3.executor - DEBUG - Thread has been shutdown: <Worker(Thread-11, stopped daemon 139715277743872)>
2014-09-19 18:29:08,146 - MainThread - awscli.customizations.s3.executor - DEBUG - Waiting for thread to shutdown: <Worker(Thread-12, stopped daemon 139715269351168)>
2014-09-19 18:29:08,146 - MainThread - awscli.customizations.s3.executor - DEBUG - Thread has been shutdown: <Worker(Thread-12, stopped daemon 139715269351168)>
2014-09-19 18:29:08,146 - MainThread - awscli.customizations.s3.executor - DEBUG - Queueing end sentinel for result thread.
2014-09-19 18:29:08,146 - MainThread - awscli.customizations.s3.executor - DEBUG - Queueing end sentinel for IO thread.
2014-09-19 18:29:08,146 - Thread-1 - awscli.customizations.s3.executor - DEBUG - Shutdown request received in print thread, shutting down print thread.
2014-09-19 18:29:08,146 - Thread-2 - awscli.customizations.s3.executor - DEBUG - Shutdown request received in IO thread, shutting down.
2014-09-19 18:29:08,146 - MainThread - awscli.customizations.s3.executor - DEBUG - Waiting for result thread to shutdown.
2014-09-19 18:29:08,147 - MainThread - awscli.customizations.s3.executor - DEBUG - Waiting for IO thread to shutdown.
2014-09-19 18:29:08,147 - MainThread - awscli.customizations.s3.executor - DEBUG - All threads have been shutdown.

Any ideas?
I would prefer to use AWS_CONFIG_FILE instead of KEY and SECRET

Thanks, - Jesse

guidance

Most helpful comment

Here's what I'd try:

# 1. Run "aws configure" and enter your credentials.
# This will ensure the values are written to the correct file location.


$ aws configure
AWS Access Key ID [****************ABCD]: foo
AWS Secret Access Key [****************ABCD]: bar
Default region name [us-west-2]: us-west-2
Default output format [None]:

# 2. Then verify the configuration values, and make sure
# they are shown in the config file.

$ aws configure list
      Name                    Value             Type    Location
      ----                    -----             ----    --------
   profile                <not set>             None    None
access_key     ****************ABCD      config-file
secret_key     ****************ABCD      config-file
    region                us-west-2      config-file    ~/.aws/config

All 18 comments

Here's what I'd try:

# 1. Run "aws configure" and enter your credentials.
# This will ensure the values are written to the correct file location.


$ aws configure
AWS Access Key ID [****************ABCD]: foo
AWS Secret Access Key [****************ABCD]: bar
Default region name [us-west-2]: us-west-2
Default output format [None]:

# 2. Then verify the configuration values, and make sure
# they are shown in the config file.

$ aws configure list
      Name                    Value             Type    Location
      ----                    -----             ----    --------
   profile                <not set>             None    None
access_key     ****************ABCD      config-file
secret_key     ****************ABCD      config-file
    region                us-west-2      config-file    ~/.aws/config

@jamesls - Thanks, that helped expose my issue

  • I was installing awscli using chef and my chef configuration had a typo aws_acces_key_id vs aws_access_key_id - doh!

Tried running aws configure. Gave all the details but still doesn't work for mw. I am on a mac.

aws configure list
Name Value Type Location
---- ----- ---- --------
profile None None
access_key None None
secret_key None None
region None None

@pranshu1992, this thread is old but I just had the same thing happen to me. I ran aws configure for a particular profile and when I ran aws configure list, my configuration list was empty (even though my .aws/ configure and connection files had values in them). To get it to work, I set the AWS_DEFAULT_PROFILE parameter on the command line to the same profile I configured and I was able to see my configuration information.

I had the same problem with aws configure list not printing the configured values. I got it to work by adding --profile xxx with the xxx being the configured profile name in ~/.aws/credentials. Editing the credential file to have the profile name [default] made aws configure list print the configured values as expected.

I had the same problem on OS X using 'aws s3 sync ...'.

I'm using these files to hold AWS credentials and config:

  • ~/.aws/credentials
  • ~/.aws/config

I have no AWS environment vars set.

If I rely on a default profile it will not find the credentials. This is the case if I leave off the profile switch on the command line or if I use --profile default

However, if I give the profile a name other than _default_ (in the credentials & config files) and add the command line switch '--profile profile-name' it all works fine. I'm using this as my work-around.

Looks like there is an issue with handling the default profile in the credentials file.

EDIT: It looks like this issue has a proper solution now, so there is no need to run this command with sudo. The rest of this comment is now invalid, but I'm leaving it here to add some historical context to this thread.


I had a similar issue to most of you. Turns out I just needed to throw in a sudo at the start of the aws configure command:

sudo aws configure

Then my script has the correct privileges to read from the config file.

Is it possible not run with sudo?

@rochapablo Yes, even with sudo the configuration files were not saving for me.

Here's the solution: just change the ownership to your local user account in my case it is "jr", just replace "jr" with your username (and staff is the default group used by OSX)

Example:

sudo chown -R jr:staff ~/.aws

Thank you. I'm not sure what I did, but some how it started to work without the need of sudo.

Just adding to to solution already available here: I have created default profile which solved the problem for me:

My config file

[default]
output=json
region=xxxxxxx

and my credentials file has this

[default]
aws_access_key_id=XXXXXXXX
aws_secret_access_key=XXXXXX

@house9 - Thank you for reporting this issue. It appears the guidance provide by @jamesls and other GitHub users have ruled out a bug in the CLI. Please reply if there are any other questions or feedback on how we can improve our documentation.

@justnance - I reported this issue on 2014-09-19, I was able to determine user error on my part a day later: 2014-09-20, I promptly closed this issue at that time, somebody else re-opened it 2 years later 2016-09-30.

It is all good as far as I am concerned.

@house9 - Thanks for the feedback. I'm glad it was resolved quickly even though the issue was reopened.

Just in case this helps someone I wanted to add what was wrong with my ~/.aws/credentials was that had this format for some reason. Preeetty sure it wasn't me but ¯\_(ツ)_/¯

aws_access_key_id=XXXXXXXX[default]
aws_secret_access_key=XXXXXX

and changing it to the below fixed it

[default]
aws_access_key_id=XXXXXXXX
aws_secret_access_key=XXXXXX

@liamroth - Thanks for the update. The change you made is correct and our documentation goes into more detail and has some examples.

Related Links:
https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html
https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html

It was happening because you did not setup the default user

user@ip:~/.aws$ cat credentials 
[user1]
aws_access_key_id = ####
aws_secret_access_key = ****
[default]
aws_access_key_id = ####
aws_secret_access_key = ****

@jamesls 's answer worked for me

try $ aws configure

if you are using aws2 then make sure you use $ aws2 configure

I found that aws cli was failing due to not being able to reach the link-local 169.254.169.254 address used for ec2 metadata. As documented here, adding that IP to no_proxy environment variable fixed the issue for me:

$ export NO_PROXY=169.254.169.254
Was this page helpful?
0 / 5 - 0 ratings