aws-samples / amazon-guardduty-multiaccount-scripts

This script automates the process of running the GuardDuty multi-account workflow across a group of accounts that are in your control
Apache License 2.0
130 stars 71 forks source link

Exceptions thrown in eu-west-3 #17

Closed AndrewFOSS closed 6 years ago

AndrewFOSS commented 6 years ago

When I run this script I get a bunch of exceptions and errors when enabling GuardDuty in eu-west-3. The error is thrown immediately upon running the script. All other regions seem to operate fine.

when running boto3 1.7.54 (botocore 1.10.54) this is the error that is thrown:

python enableguardduty.py --master_account ######## ./AWS/cloudformation-np+p-accounts.csv --assume_role AWSCloudFormationStackSetExecutionRole --enabled_regions eu-west-3

Enabling members in these regions: ['eu-west-3']

Assumed session for ########.

Traceback (most recent call last):
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\vendored\requests\packages\urllib3\connectionpool.py", line 544, in urlopen
    body=body, headers=headers)
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\vendored\requests\packages\urllib3\connectionpool.py", line 341, in _make_request
    self._validate_conn(conn)
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\vendored\requests\packages\urllib3\connectionpool.py", line 761, in _validate_conn
    conn.connect()
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\vendored\requests\packages\urllib3\connection.py", line 238, in connect
    ssl_version=resolved_ssl_version)
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\vendored\requests\packages\urllib3\util\ssl_.py", line 279, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 412, in wrap_socket
    session=session
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 850, in _create
    self.do_handshake()
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 1108, in do_handshake
    self._sslobj.do_handshake()
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\vendored\requests\adapters.py", line 370, in send
    timeout=timeout
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\vendored\requests\packages\urllib3\connectionpool.py", line 597, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\vendored\requests\packages\urllib3\util\retry.py", line 245, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\vendored\requests\packages\urllib3\packages\six.py", line 309, in reraise
    raise value.with_traceback(tb)
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\vendored\requests\packages\urllib3\connectionpool.py", line 544, in urlopen
    body=body, headers=headers)
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\vendored\requests\packages\urllib3\connectionpool.py", line 341, in _make_request
    self._validate_conn(conn)
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\vendored\requests\packages\urllib3\connectionpool.py", line 761, in _validate_conn
    conn.connect()
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\vendored\requests\packages\urllib3\connection.py", line 238, in connect
    ssl_version=resolved_ssl_version)
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\vendored\requests\packages\urllib3\util\ssl_.py", line 279, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 412, in wrap_socket
    session=session
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 850, in _create
    self.do_handshake()
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 1108, in do_handshake
    self._sslobj.do_handshake()
botocore.vendored.requests.packages.urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "enableguardduty.py", line 168, in <module>
    detector_dict = list_detectors(gd_client, aws_region)
  File "enableguardduty.py", line 102, in list_detectors
    detector_dict = client.list_detectors()
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\client.py", line 314, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\client.py", line 599, in _make_api_call
    operation_model, request_dict)
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\endpoint.py", line 148, in make_request
    return self._send_request(request_dict, operation_model)
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\endpoint.py", line 177, in _send_request
    success_response, exception):
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\endpoint.py", line 273, in _needs_retry
    caught_exception=caught_exception, request_dict=request_dict)
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\hooks.py", line 227, in emit
    return self._emit(event_name, kwargs)
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\hooks.py", line 210, in _emit
    response = handler(**kwargs)
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\retryhandler.py", line 183, in __call__
    if self._checker(attempts, response, caught_exception):
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\retryhandler.py", line 251, in __call__
    caught_exception)
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\retryhandler.py", line 277, in _should_retry
    return self._checker(attempt_number, response, caught_exception)
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\retryhandler.py", line 317, in __call__
    caught_exception)
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\retryhandler.py", line 223, in __call__
    attempt_number, caught_exception)
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\retryhandler.py", line 359, in _check_caught_exception
    raise caught_exception
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\endpoint.py", line 222, in _get_response
    proxies=self.proxies, timeout=self.timeout)
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\vendored\requests\sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "C:\...\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\vendored\requests\adapters.py", line 415, in send
    raise ConnectionError(err, request=request)
botocore.vendored.requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

I updated my boto3 (1.8.7) and botocore (1.11.7) to the most recent version, and now new errors are thrown...


Enabling members in these regions: ['eu-west-3']
Assumed session for #####.

Traceback (most recent call last):
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 849, in _validate_conn
    conn.connect()
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connection.py", line 356, in connect
    ssl_context=context)
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\ssl_.py", line 359, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 412, in wrap_socket
    session=session
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 850, in _create
    self.do_handshake()
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 1108, in do_handshake
    self._sslobj.do_handshake()
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\httpsession.py", line 242, in send
    decode_content=False,
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\retry.py", line 343, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\packages\six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 849, in _validate_conn
    conn.connect()
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connection.py", line 356, in connect
    ssl_context=context)
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\ssl_.py", line 359, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 412, in wrap_socket
    session=session
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 850, in _create
    self.do_handshake()
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 1108, in do_handshake
    self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "enableguardduty.py", line 168, in <module>
    detector_dict = list_detectors(gd_client, aws_region)
  File "enableguardduty.py", line 102, in list_detectors
    detector_dict = client.list_detectors()
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\client.py", line 314, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\client.py", line 599, in _make_api_call
    operation_model, request_dict)
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\endpoint.py", line 102, in make_request
    return self._send_request(request_dict, operation_model)
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\endpoint.py", line 135, in _send_request
    success_response, exception):
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\endpoint.py", line 202, in _needs_retry
    caught_exception=caught_exception, request_dict=request_dict)
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\hooks.py", line 227, in emit
    return self._emit(event_name, kwargs)
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\hooks.py", line 360, in _emit
    aliased_event_name, kwargs, stop_on_response
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\hooks.py", line 210, in _emit
    response = handler(**kwargs)
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\retryhandler.py", line 183, in __call__
    if self._checker(attempts, response, caught_exception):
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\retryhandler.py", line 251, in __call__
    caught_exception)
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\retryhandler.py", line 277, in _should_retry
    return self._checker(attempt_number, response, caught_exception)
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\retryhandler.py", line 317, in __call__
    caught_exception)
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\retryhandler.py", line 223, in __call__
    attempt_number, caught_exception)
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\retryhandler.py", line 359, in _check_caught_exception
    raise caught_exception
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\endpoint.py", line 173, in _get_response
    http_response = self._send(request)
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\endpoint.py", line 215, in _send
    return self.http_session.send(request)
  File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\botocore\httpsession.py", line 273, in send
    endpoint_url=request.url
botocore.exceptions.ConnectionClosedError: Connection was closed before we received a valid response from endpoint URL: "https://guardduty.eu-west-3.amazonaws.com/detector".
ryanholland commented 6 years ago

Hi, I am unable to reproduce this error and the exception seems to indicate that the endpoint was not reachable by your client. Do you perhaps have any proxies or other filtering in place that would prevent connectivity to the Paris endpoint?