aws-samples / service-screener-v2

A tool for customers to evaluate their AWS service configurations based on AWS and community best practices and receive recommendations on potential improvements.
Apache License 2.0
345 stars 65 forks source link

NoCredentialsError #119

Closed mhan808 closed 5 months ago

mhan808 commented 5 months ago

Describe the bug hello. After receiving permission through Assume role, we try to run service-screener by specifying a profile. When I created and tested a sample code that called get_caller_identity of the profile where the error occurred, a normal response was returned.

If I'm missing something, please advise.

 -- Acquiring identify info...
Traceback (most recent call last):
  File "/Users/service-screener/service-screener-v2/main.py", line 154, in <module>
    Config.setAccountInfo(tempConfig)
  File "/Users/service-screener/service-screener-v2/utils/Config.py", line 105, in setAccountInfo
    resp = stsClient.get_caller_identity()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/service-screener/service-screener-v2/lib/python3.12/site-packages/botocore/client.py", line 530, in _api_call
    return self._make_api_call(operation_name, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/service-screener/service-screener-v2/lib/python3.12/site-packages/botocore/client.py", line 947, in _make_api_call
    http, parsed_response = self._make_request(
                            ^^^^^^^^^^^^^^^^^^^
  File "/Users/service-screener/service-screener-v2/lib/python3.12/site-packages/botocore/client.py", line 970, in _make_request
    return self._endpoint.make_request(operation_model, request_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/service-screener/service-screener-v2/lib/python3.12/site-packages/botocore/endpoint.py", line 119, in make_request
    return self._send_request(request_dict, operation_model)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/service-screener/service-screener-v2/lib/python3.12/site-packages/botocore/endpoint.py", line 198, in _send_request
    request = self.create_request(request_dict, operation_model)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/service-screener/service-screener-v2/lib/python3.12/site-packages/botocore/endpoint.py", line 134, in create_request
    self._event_emitter.emit(
  File "/Users/service-screener/service-screener-v2/lib/python3.12/site-packages/botocore/hooks.py", line 412, in emit
    return self._emitter.emit(aliased_event_name, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/service-screener/service-screener-v2/lib/python3.12/site-packages/botocore/hooks.py", line 256, in emit
    return self._emit(event_name, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/service-screener/service-screener-v2/lib/python3.12/site-packages/botocore/hooks.py", line 239, in _emit
    response = handler(**kwargs)
               ^^^^^^^^^^^^^^^^^
  File "/Users/service-screener/service-screener-v2/lib/python3.12/site-packages/botocore/signers.py", line 105, in handler
    return self.sign(operation_name, request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/service-screener/service-screener-v2/lib/python3.12/site-packages/botocore/signers.py", line 189, in sign
    auth.add_auth(request)
  File "/Users/service-screener/service-screener-v2/lib/python3.12/site-packages/botocore/auth.py", line 418, in add_auth
    raise NoCredentialsError()
botocore.exceptions.NoCredentialsError: Unable to locate credentials

Full commands used to reproduce this bug screener --regions ap-northeast-2 --profile profilename

Execution Environment (PLEASE FILL THIS UP IF YOU ARE NOT RUNNING THIS IN AWS CLOUDSHELL):

kuettai commented 5 months ago

Hey. It been a while since we develop on Mac itself due to the error on multi-threading. You can try to run it on AWS Cloud9 tho.

Can you describe how you "AssumeRole" in this case?

aws configure --profile <SAMPLE PROFILE>

Meanwhile, i will spend sometimes to simulate it in Mac in next few hours

kuettai commented 5 months ago

Managed to simulate and perform fixes both for multi-threading on MacOS + --profile support