Skip to content

NoCredentialsError if no credentials defined #1924

@t-chaik

Description

@t-chaik

Testing 1.3.7 and the fix for #1793:

boto                     2.49.0
boto3                    1.9.37
botocore                 1.12.37
moto                     1.3.7

Trying to run the context manager example:

Python 3.6.7 (default, Oct 21 2018, 08:08:16) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import boto3
>>> from moto import mock_s3
>>> with mock_s3():
...     conn = boto3.resource('s3', region_name='us-east-1')
...     conn.create_bucket(Bucket='mybucket')
... 

Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
  File "/home/martinblanchard/Work/env/buildgrid/lib/python3.6/site-packages/boto3/resources/factory.py", line 520, in do_action
    response = action(self, *args, **kwargs)
  File "/home/martinblanchard/Work/env/buildgrid/lib/python3.6/site-packages/boto3/resources/action.py", line 83, in __call__
    response = getattr(parent.meta.client, operation_name)(**params)
  File "/home/martinblanchard/Work/env/buildgrid/lib/python3.6/site-packages/botocore/client.py", line 320, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/home/martinblanchard/Work/env/buildgrid/lib/python3.6/site-packages/botocore/client.py", line 610, in _make_api_call
    operation_model, request_dict)
  File "/home/martinblanchard/Work/env/buildgrid/lib/python3.6/site-packages/botocore/endpoint.py", line 102, in make_request
    return self._send_request(request_dict, operation_model)
  File "/home/martinblanchard/Work/env/buildgrid/lib/python3.6/site-packages/botocore/endpoint.py", line 132, in _send_request
    request = self.create_request(request_dict, operation_model)
  File "/home/martinblanchard/Work/env/buildgrid/lib/python3.6/site-packages/botocore/endpoint.py", line 116, in create_request
    operation_name=operation_model.name)
  File "/home/martinblanchard/Work/env/buildgrid/lib/python3.6/site-packages/botocore/hooks.py", line 356, in emit
    return self._emitter.emit(aliased_event_name, **kwargs)
  File "/home/martinblanchard/Work/env/buildgrid/lib/python3.6/site-packages/botocore/hooks.py", line 228, in emit
    return self._emit(event_name, kwargs)
  File "/home/martinblanchard/Work/env/buildgrid/lib/python3.6/site-packages/botocore/hooks.py", line 211, in _emit
    response = handler(**kwargs)
  File "/home/martinblanchard/Work/env/buildgrid/lib/python3.6/site-packages/botocore/signers.py", line 90, in handler
    return self.sign(operation_name, request)
  File "/home/martinblanchard/Work/env/buildgrid/lib/python3.6/site-packages/botocore/signers.py", line 157, in sign
    auth.add_auth(request)
  File "/home/martinblanchard/Work/env/buildgrid/lib/python3.6/site-packages/botocore/auth.py", line 425, in add_auth
    super(S3SigV4Auth, self).add_auth(request)
  File "/home/martinblanchard/Work/env/buildgrid/lib/python3.6/site-packages/botocore/auth.py", line 357, in add_auth
    raise NoCredentialsError
botocore.exceptions.NoCredentialsError: Unable to locate credentials

Setting AWS_SECRET_ACCESS_KEY and AWS_ACCESS_KEY_ID (to whatever) seems to fix the issue. Not sure if mocking without providing any credential is something actually supported by moto, but it used to work with moto<1.3.7, boto3<1.8.0 and botocore<1.11.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions