title: sam local invoke gets connectionRefused when accessing S3 from localstack
body: <p>I'm running localstack where I create an s3 bucket. But when I invoke a lambda function with SAM to list the buckets, the connection is refused.</p>
  <p>I start localstack with</p>
  <pre><code>localstack start
  </code></pre>
  <p>then I create and list a bucket with a python script:</p>
  <pre><code>import boto3
  
  BUCKET_NAME = &quot;mybucket&quot;
  HOST_ADDRESS= &quot;http://localhost:4566&quot;
  
  s3_client = boto3.client('s3', region_name='us-east-1', endpoint_url=HOST_ADDRESS)
  
  s3_client.create_bucket(Bucket=BUCKET_NAME)
  </code></pre>
  <p>Then I list the buckets with</p>
  <pre><code>import boto3
  
  s3_client = boto3.client('s3', endpoint_url=&quot;http://localhost:4566&quot;)
  
  for bucket in s3_client.list_buckets()[&quot;Buckets&quot;]:
      print(bucket['Name'])
  </code></pre>
  <p>Now I invoke my lambda function that does the exact same thing with <code>sam build</code> and <code>sam local invoke --profile=localstack</code>. The profile localstack constains the credentials and region for my localstack.
  The code is</p>
  <pre><code>#!/usr/bin/python3
  import boto3
  
  HOST_ADDRESS= &quot;http://localhost:4566&quot;
  
  s3_client = boto3.client('s3', endpoint_url=HOST_ADDRESS)
  
  def lambda_handler(event, context):
      s3_client.list_buckets()
      return { &quot;statusCode&quot;: 200 }
  </code></pre>
  <p>the template:</p>
  <pre><code>AWSTemplateFormatVersion: '2010-09-09'
  Transform: 'AWS::Serverless-2016-10-31'
  
  Description: Lambda that reads from an s3 bucket
  
  Resources:
    FetchFunction:
      Type: 'AWS::Serverless::Function'
      Properties:
        FunctionName: bucketFetchSAM
        Handler: app.lambda_handler
        Runtime: python3.8
        CodeUri: fetch_new/
        Timeout: 20
        Policies:
          - Version: '2012-10-17'
            Statement:
              - Effect: Allow
                Action:
                  - 's3:ListAllMyBuckets'
                Resource: '*'
  </code></pre>
  <p>This produces the following error message</p>
  <pre><code>START RequestId: 24050f46-f66c-4916-a082-b7f5ce2deda7 Version: $LATEST
      raise EndpointConnectionError(endpoint_url=request.url, error=e)ponset_exceptionlhost:4566/&quot;
  {
      &quot;errorMessage&quot;: &quot;Could not connect to the endpoint URL: \&quot;http://localhost:4566/\&quot;&quot;,
      &quot;errorType&quot;: &quot;EndpointConnectionError&quot;,
      &quot;stackTrace&quot;: [
          &quot;  File \&quot;/var/task/app.py\&quot;, line 13, in lambda_handler\n    s3_client.list_buckets()\n&quot;,
          &quot;  File \&quot;/var/runtime/botocore/client.py\&quot;, line 391, in _api_call\n    return self._make_api_call(operation_name, kwargs)\n&quot;,
          &quot;  File \&quot;/var/runtime/botocore/client.py\&quot;, line 705, in _make_api_call\n    http, parsed_response = self._make_request(\n&quot;,
          &quot;  File \&quot;/var/runtime/botocore/client.py\&quot;, line 725, in _make_request\n    return self._endpoint.make_request(operation_model, request_dict)\n&quot;,
          &quot;  File \&quot;/var/runtime/botocore/endpoint.py\&quot;, line 104, in make_request\n    return self._send_request(request_dict, operation_model)\n&quot;,
          &quot;  File \&quot;/var/runtime/botocore/endpoint.py\&quot;, line 138, in _send_request\n    while self._needs_retry(attempts, operation_model, request_dict,\n&quot;,
          &quot;  File \&quot;/var/runtime/botocore/endpoint.py\&quot;, line 254, in _needs_retry\n    responses = self._event_emitter.emit(\n&quot;,
          &quot;  File \&quot;/var/runtime/botocore/hooks.py\&quot;, line 357, in emit\n    return self._emitter.emit(aliased_event_name, **kwargs)\n&quot;,
          &quot;  File \&quot;/var/runtime/botocore/hooks.py\&quot;, line 228, in emit\n    return self._emit(event_name, kwargs)\n&quot;,
          &quot;  File \&quot;/var/runtime/botocore/hooks.py\&quot;, line 211, in _emit\n    response = handler(**kwargs)\n&quot;,
          &quot;  File \&quot;/var/runtime/botocore/retryhandler.py\&quot;, line 183, in __call__\n    if self._checker(attempts, response, caught_exception):\n&quot;,
          &quot;  File \&quot;/var/runtime/botocore/retryhandler.py\&quot;, line 250, in __call__\n    should_retry = self._should_retry(attempt_number, response,\n&quot;,
          &quot;  File \&quot;/var/runtime/botocore/retryhandler.py\&quot;, line 277, in _should_retry\n    return self._checker(attempt_number, response, caught_exception)\n&quot;,
          &quot;  File \&quot;/var/runtime/botocore/retryhandler.py\&quot;, line 316, in __call__\n    checker_response = checker(attempt_number, response,\n&quot;,
          &quot;  File \&quot;/var/runtime/botocore/retryhandler.py\&quot;, line 222, in __call__\n    return self._check_caught_exception(\n&quot;,
          &quot;  File \&quot;/var/runtime/botocore/retryhandler.py\&quot;, line 359, in _check_caught_exception\n    raise caught_exception\n&quot;,
          &quot;  File \&quot;/var/runtime/botocore/endpoint.py\&quot;, line 201, in _do_get_response\n    http_response = self._send(request)\n&quot;,
          &quot;  File \&quot;/var/runtime/botocore/endpoint.py\&quot;, line 270, in _send\n    return self.http_session.send(request)\n&quot;,
          &quot;  File \&quot;/var/runtime/botocore/httpsession.py\&quot;, line 438, in send\n    raise EndpointConnectionError(endpoint_url=request.url, error=e)\n&quot;
      ]
  }
  END RequestId: 24050f46-f66c-4916-a082-b7f5ce2deda7
  </code></pre>
  <p>I am especially confused because the commands I am using clearly work when used outside of sam, but within sam it seems the the bucket is either not found or not accessible or that there is a lack of authentication.</p>
  <p>When I put</p>
  <pre><code>logger = logging.getLogger()
  logger.setLevel(logging.DEBUG)
  </code></pre>
  <p>into the lambda code I get these logs:</p>
  <pre><code>[DEBUG] 2022-09-10T11:37:48.729Z    3b4786a3-2b51-4213-8611-d6ff374211a2    Event before-parameter-build.s3.ListBuckets: calling handler &lt;function validate_bucket_name at 0x7f2c32b7a820&gt;
  [DEBUG] 2022-09-10T11:37:48.729Z    3b4786a3-2b51-4213-8611-d6ff374211a2    Event before-parameter-build.s3.ListBuckets: calling handler &lt;bound method S3RegionRedirector.redirect_from_cache of &lt;botocore.utils.S3RegionRedirector object at 0x7f2c317b1910&gt;&gt;
  [DEBUG] 2022-09-10T11:37:48.729Z    3b4786a3-2b51-4213-8611-d6ff374211a2    Event before-parameter-build.s3.ListBuckets: calling handler &lt;bound method S3ArnParamHandler.handle_arn of &lt;botocore.utils.S3ArnParamHandler object at 0x7f2c317b19d0&gt;&gt;
  [DEBUG] 2022-09-10T11:37:48.729Z    3b4786a3-2b51-4213-8611-d6ff374211a2    Event before-parameter-build.s3.ListBuckets: calling handler &lt;function generate_idempotent_uuid at 0x7f2c32b7a670&gt;
  [DEBUG] 2022-09-10T11:37:48.729Z    3b4786a3-2b51-4213-8611-d6ff374211a2    Event before-call.s3.ListBuckets: calling handler &lt;function add_expect_header at 0x7f2c32b7ab80&gt;
  [DEBUG] 2022-09-10T11:37:48.729Z    3b4786a3-2b51-4213-8611-d6ff374211a2    Event before-call.s3.ListBuckets: calling handler &lt;bound method S3RegionRedirector.set_request_url of &lt;botocore.utils.S3RegionRedirector object at 0x7f2c317b1910&gt;&gt;
  [DEBUG] 2022-09-10T11:37:48.730Z    3b4786a3-2b51-4213-8611-d6ff374211a2    Event before-call.s3.ListBuckets: calling handler &lt;function inject_api_version_header_if_needed at 0x7f2c32b81ee0&gt;
  [DEBUG] 2022-09-10T11:37:48.730Z    3b4786a3-2b51-4213-8611-d6ff374211a2    Making request for OperationModel(name=ListBuckets) with params: {'url_path': '/', 'query_string': '', 'method': 'GET', 'headers': {'User-Agent': 'Boto3/1.20.32 Python/3.8.13 Linux/5.15.0-46-generic exec-env/AWS_Lambda_python3.8 Botocore/1.23.32'}, 'body': b'', 'url': 'http://localhost:4566/', 'context': {'client_region': 'us-east-1', 'client_config': &lt;botocore.config.Config object at 0x7f2c3259f9a0&gt;, 'has_streaming_input': False, 'auth_type': None, 'signing': {'bucket': None}}}
  [DEBUG] 2022-09-10T11:37:48.730Z    3b4786a3-2b51-4213-8611-d6ff374211a2    Event request-created.s3.ListBuckets: calling handler &lt;bound method RequestSigner.handler of &lt;botocore.signers.RequestSigner object at 0x7f2c3259f9d0&gt;&gt;
  [DEBUG] 2022-09-10T11:37:48.730Z    3b4786a3-2b51-4213-8611-d6ff374211a2    Event choose-signer.s3.ListBuckets: calling handler &lt;bound method S3EndpointSetter.set_signer of &lt;botocore.utils.S3EndpointSetter object at 0x7f2c317b1a60&gt;&gt;
  [DEBUG] 2022-09-10T11:37:48.731Z    3b4786a3-2b51-4213-8611-d6ff374211a2    Event choose-signer.s3.ListBuckets: calling handler &lt;bound method ClientCreator._default_s3_presign_to_sigv2 of &lt;botocore.client.ClientCreator object at 0x7f2c32ba3b80&gt;&gt;
  [DEBUG] 2022-09-10T11:37:48.731Z    3b4786a3-2b51-4213-8611-d6ff374211a2    Event choose-signer.s3.ListBuckets: calling handler &lt;function set_operation_specific_signer at 0x7f2c32b7a550&gt;
  [DEBUG] 2022-09-10T11:37:48.731Z    3b4786a3-2b51-4213-8611-d6ff374211a2    Event before-sign.s3.ListBuckets: calling handler &lt;bound method S3EndpointSetter.set_endpoint of &lt;botocore.utils.S3EndpointSetter object at 0x7f2c317b1a60&gt;&gt;
  [DEBUG] 2022-09-10T11:37:48.731Z    3b4786a3-2b51-4213-8611-d6ff374211a2    Using S3 path style addressing.
  [DEBUG] 2022-09-10T11:37:48.732Z    3b4786a3-2b51-4213-8611-d6ff374211a2    Calculating signature using v4 auth.
  [DEBUG] 2022-09-10T11:37:48.732Z    3b4786a3-2b51-4213-8611-d6ff374211a2    CanonicalRequest:
  GET
  /
  
  host:localhost:4566
  x-amz-content-sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
  x-amz-date:20220910T113748Z
  
  host;x-amz-content-sha256;x-amz-date
  e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
  [DEBUG] 2022-09-10T11:37:48.732Z    3b4786a3-2b51-4213-8611-d6ff374211a2    StringToSign:
  AWS4-HMAC-SHA256
  20220910T113748Z
  20220910/us-east-1/s3/aws4_request
  745622b7535d6b3346127386c068f1ada28987a487193b43981e6ca68e719eb3
  [DEBUG] 2022-09-10T11:37:48.732Z    3b4786a3-2b51-4213-8611-d6ff374211a2    Signature:
  ffe5af8ae43d86e0dff2c991546d722f70f886d8b49565467a607b20ef433042
  [DEBUG] 2022-09-10T11:37:48.732Z    3b4786a3-2b51-4213-8611-d6ff374211a2    Sending http request: &lt;AWSPreparedRequest stream_output=False, method=GET, url=http://localhost:4566/, headers={'User-Agent': b'Boto3/1.20.32 Python/3.8.13 Linux/5.15.0-46-generic exec-env/AWS_Lambda_python3.8 Botocore/1.23.32', 'X-Amz-Date': b'20220910T113748Z', 'X-Amz-Content-SHA256': b'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'Authorization': b'AWS4-HMAC-SHA256 Credential=test/20220910/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=ffe5af8ae43d86e0dff2c991546d722f70f886d8b49565467a607b20ef433042'}&gt;
  [DEBUG] 2022-09-10T11:37:48.733Z    3b4786a3-2b51-4213-8611-d6ff374211a2    Starting new HTTP connection (1): localhost:4566
  [DEBUG] 2022-09-10T11:37:48.737Z    3b4786a3-2b51-4213-8611-d6ff374211a2    Exception received when sending HTTP request.
  Traceback (most recent call last):
    File &quot;/var/task/urllib3/connection.py&quot;, line 174, in _new_conn
      conn = connection.create_connection(
    File &quot;/var/task/urllib3/util/connection.py&quot;, line 95, in create_connection
      raise err
    File &quot;/var/task/urllib3/util/connection.py&quot;, line 85, in create_connection
      sock.connect(sa)
  ConnectionRefusedError: [Errno 111] Connection refused
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;/var/runtime/botocore/httpsession.py&quot;, line 409, in send
      urllib_response = conn.urlopen(
    File &quot;/var/task/urllib3/connectionpool.py&quot;, line 787, in urlopen
      retries = retries.increment(
    File &quot;/var/task/urllib3/util/retry.py&quot;, line 525, in increment
      raise six.reraise(type(error), error, _stacktrace)
    File &quot;/var/task/urllib3/packages/six.py&quot;, line 770, in reraise
      raise value
    File &quot;/var/task/urllib3/connectionpool.py&quot;, line 703, in urlopen
      httplib_response = self._make_request(
    File &quot;/var/task/urllib3/connectionpool.py&quot;, line 398, in _make_request
      conn.request(method, url, **httplib_request_kw)
    File &quot;/var/task/urllib3/connection.py&quot;, line 239, in request
      super(HTTPConnection, self).request(method, url, body=body, headers=headers)
    File &quot;/var/lang/lib/python3.8/http/client.py&quot;, line 1256, in request
      self._send_request(method, url, body, headers, encode_chunked)
    File &quot;/var/runtime/botocore/awsrequest.py&quot;, line 92, in _send_request
      rval = super(AWSConnection, self)._send_request(
    File &quot;/var/lang/lib/python3.8/http/client.py&quot;, line 1302, in _send_request
      self.endheaders(body, encode_chunked=encode_chunked)
    File &quot;/var/lang/lib/python3.8/http/client.py&quot;, line 1251, in endheaders
      self._send_output(message_body, encode_chunked=encode_chunked)
    File &quot;/var/runtime/botocore/awsrequest.py&quot;, line 120, in _send_output
      self.send(msg)
    File &quot;/var/runtime/botocore/awsrequest.py&quot;, line 204, in send
      return super(AWSConnection, self).send(str)
    File &quot;/var/lang/lib/python3.8/http/client.py&quot;, line 951, in send
      self.connect()
    File &quot;/var/task/urllib3/connection.py&quot;, line 205, in connect
      conn = self._new_conn()
    File &quot;/var/task/urllib3/connection.py&quot;, line 186, in _new_conn
      raise NewConnectionError(
  urllib3.exceptions.NewConnectionError: &lt;botocore.awsrequest.AWSHTTPConnection object at 0x7f2c317e2100&gt;: Failed to establish a new connection: [Errno 111] Connection refused
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;/var/runtime/botocore/endpoint.py&quot;, line 201, in _do_get_response
      http_response = self._send(request)
    File &quot;/var/runtime/botocore/endpoint.py&quot;, line 270, in _send
      return self.http_session.send(request)
    File &quot;/var/runtime/botocore/httpsession.py&quot;, line 438, in send
      raise EndpointConnectionError(endpoint_url=request.url, error=e)
  botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: &quot;http://localhost:4566/&quot;[DEBUG] 2022-09-10T11:37:48.740Z    3b4786a3-2b51-4213-8611-d6ff374211a2    Event needs-retry.s3.ListBuckets: calling handler &lt;botocore.retryhandler.RetryHandler object at 0x7f2c317b18b0&gt;
  [DEBUG] 2022-09-10T11:37:48.741Z    3b4786a3-2b51-4213-8611-d6ff374211a2    retry needed, retryable exception caught: Could not connect to the endpoint URL: &quot;http://localhost:4566/&quot;
  Traceback (most recent call last):
    File &quot;/var/task/urllib3/connection.py&quot;, line 174, in _new_conn
      conn = connection.create_connection(
    File &quot;/var/task/urllib3/util/connection.py&quot;, line 95, in create_connection
      raise err
    File &quot;/var/task/urllib3/util/connection.py&quot;, line 85, in create_connection
      sock.connect(sa)
  ConnectionRefusedError: [Errno 111] Connection refused
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;/var/runtime/botocore/httpsession.py&quot;, line 409, in send
      urllib_response = conn.urlopen(
    File &quot;/var/task/urllib3/connectionpool.py&quot;, line 787, in urlopen
      retries = retries.increment(
    File &quot;/var/task/urllib3/util/retry.py&quot;, line 525, in increment
      raise six.reraise(type(error), error, _stacktrace)
    File &quot;/var/task/urllib3/packages/six.py&quot;, line 770, in reraise
      raise value
    File &quot;/var/task/urllib3/connectionpool.py&quot;, line 703, in urlopen
      httplib_response = self._make_request(
    File &quot;/var/task/urllib3/connectionpool.py&quot;, line 398, in _make_request
      conn.request(method, url, **httplib_request_kw)
    File &quot;/var/task/urllib3/connection.py&quot;, line 239, in request
      super(HTTPConnection, self).request(method, url, body=body, headers=headers)
    File &quot;/var/lang/lib/python3.8/http/client.py&quot;, line 1256, in request
      self._send_request(method, url, body, headers, encode_chunked)
    File &quot;/var/runtime/botocore/awsrequest.py&quot;, line 92, in _send_request
      rval = super(AWSConnection, self)._send_request(
    File &quot;/var/lang/lib/python3.8/http/client.py&quot;, line 1302, in _send_request
      self.endheaders(body, encode_chunked=encode_chunked)
    File &quot;/var/lang/lib/python3.8/http/client.py&quot;, line 1251, in endheaders
      self._send_output(message_body, encode_chunked=encode_chunked)
    File &quot;/var/runtime/botocore/awsrequest.py&quot;, line 120, in _send_output
      self.send(msg)
    File &quot;/var/runtime/botocore/awsrequest.py&quot;, line 204, in send
      return super(AWSConnection, self).send(str)
    File &quot;/var/lang/lib/python3.8/http/client.py&quot;, line 951, in send
      self.connect()
    File &quot;/var/task/urllib3/connection.py&quot;, line 205, in connect
      conn = self._new_conn()
    File &quot;/var/task/urllib3/connection.py&quot;, line 186, in _new_conn
      raise NewConnectionError(
  urllib3.exceptions.NewConnectionError: &lt;botocore.awsrequest.AWSHTTPConnection object at 0x7f2c317e2100&gt;: Failed to establish a new connection: [Errno 111] Connection refused
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;/var/runtime/botocore/retryhandler.py&quot;, line 269, in _should_retry
      return self._checker(attempt_number, response, caught_exception)
    File &quot;/var/runtime/botocore/retryhandler.py&quot;, line 316, in __call__
      checker_response = checker(attempt_number, response,
    File &quot;/var/runtime/botocore/retryhandler.py&quot;, line 222, in __call__
      return self._check_caught_exception(
    File &quot;/var/runtime/botocore/retryhandler.py&quot;, line 359, in _check_caught_exception
      raise caught_exception
    File &quot;/var/runtime/botocore/endpoint.py&quot;, line 201, in _do_get_response
      http_response = self._send(request)
    File &quot;/var/runtime/botocore/endpoint.py&quot;, line 270, in _send
      return self.http_session.send(request)
    File &quot;/var/runtime/botocore/httpsession.py&quot;, line 438, in send
      raise EndpointConnectionError(endpoint_url=request.url, error=e)
  botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: &quot;http://localhost:4566/&quot;[DEBUG] 2022-09-10T11:37:48.741Z    3b4786a3-2b51-4213-8611-d6ff374211a2    Retry needed, action of: 0.15278091352455614
  </code></pre>
  <p>The snippet <code>[DEBUG]    2022-09-10T11:37:48.732Z    3b4786a3-2b51-4213-8611-d6ff374211a2    Sending http request: &lt;AWSPreparedRequest stream_output=False, method=GET, url=http://localhost:4566/, headers={'User-Agent': b'Boto3/1.20.32 Python/3.8.13 Linux/5.15.0-46-generic exec-env/AWS_Lambda_python3.8 Botocore/1.23.32', 'X-Amz-Date': b'20220910T113748Z', 'X-Amz-Content-SHA256': b'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'Authorization': b'AWS4-HMAC-SHA256 Credential=test/20220910/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=ffe5af8ae43d86e0dff2c991546d722f70f886d8b49565467a607b20ef433042'}&gt;</code> confirms that the right address and credentials are submitted.</p>
  <p>I've also found a way to generate logs for my local script, but I cannot make out any significant difference:</p>
  <pre><code>2022-09-10 17:26:10,363 botocore.hooks [DEBUG] Changing event name from creating-client-class.iot-data to creating-client-class.iot-data-plane
  2022-09-10 17:26:10,365 botocore.hooks [DEBUG] Changing event name from before-call.apigateway to before-call.api-gateway
  2022-09-10 17:26:10,366 botocore.hooks [DEBUG] Changing event name from request-created.machinelearning.Predict to request-created.machine-learning.Predict
  2022-09-10 17:26:10,367 botocore.hooks [DEBUG] Changing event name from before-parameter-build.autoscaling.CreateLaunchConfiguration to before-parameter-build.auto-scaling.CreateLaunchConfiguration
  2022-09-10 17:26:10,367 botocore.hooks [DEBUG] Changing event name from before-parameter-build.route53 to before-parameter-build.route-53
  2022-09-10 17:26:10,368 botocore.hooks [DEBUG] Changing event name from request-created.cloudsearchdomain.Search to request-created.cloudsearch-domain.Search
  2022-09-10 17:26:10,369 botocore.hooks [DEBUG] Changing event name from docs.*.autoscaling.CreateLaunchConfiguration.complete-section to docs.*.auto-scaling.CreateLaunchConfiguration.complete-section
  2022-09-10 17:26:10,370 botocore.hooks [DEBUG] Changing event name from before-parameter-build.logs.CreateExportTask to before-parameter-build.cloudwatch-logs.CreateExportTask
  2022-09-10 17:26:10,371 botocore.hooks [DEBUG] Changing event name from docs.*.logs.CreateExportTask.complete-section to docs.*.cloudwatch-logs.CreateExportTask.complete-section
  2022-09-10 17:26:10,371 botocore.hooks [DEBUG] Changing event name from before-parameter-build.cloudsearchdomain.Search to before-parameter-build.cloudsearch-domain.Search
  2022-09-10 17:26:10,371 botocore.hooks [DEBUG] Changing event name from docs.*.cloudsearchdomain.Search.complete-section to docs.*.cloudsearch-domain.Search.complete-section
  2022-09-10 17:26:10,376 botocore.utils [DEBUG] IMDS ENDPOINT: http://169.254.169.254/
  2022-09-10 17:26:10,377 botocore.credentials [DEBUG] Looking for credentials via: env
  2022-09-10 17:26:10,377 botocore.credentials [DEBUG] Looking for credentials via: assume-role
  2022-09-10 17:26:10,377 botocore.credentials [DEBUG] Looking for credentials via: assume-role-with-web-identity
  2022-09-10 17:26:10,377 botocore.credentials [DEBUG] Looking for credentials via: sso
  2022-09-10 17:26:10,377 botocore.credentials [DEBUG] Looking for credentials via: shared-credentials-file
  2022-09-10 17:26:10,378 botocore.credentials [INFO] Found credentials in shared credentials file: ~/.aws/credentials
  2022-09-10 17:26:10,378 botocore.loaders [DEBUG] Loading JSON file: /home/.../sam_bucket_fetch/samvenv/lib/python3.8/site-packages/botocore/data/endpoints.json
  2022-09-10 17:26:10,390 botocore.loaders [DEBUG] Loading JSON file: /home/.../sam_bucket_fetch/samvenv/lib/python3.8/site-packages/botocore/data/sdk-default-configuration.json
  2022-09-10 17:26:10,390 botocore.hooks [DEBUG] Event choose-service-name: calling handler &lt;function handle_service_name_alias at 0x7fa830c424c0&gt;
  2022-09-10 17:26:10,400 botocore.loaders [DEBUG] Loading JSON file: /home/.../sam_bucket_fetch/samvenv/lib/python3.8/site-packages/botocore/data/s3/2006-03-01/service-2.json
  2022-09-10 17:26:10,408 botocore.hooks [DEBUG] Event creating-client-class.s3: calling handler &lt;function add_generate_presigned_post at 0x7fa830cbcd30&gt;
  2022-09-10 17:26:10,408 botocore.hooks [DEBUG] Event creating-client-class.s3: calling handler &lt;function lazy_call.&lt;locals&gt;._handler at 0x7fa830b7e160&gt;
  2022-09-10 17:26:10,422 botocore.hooks [DEBUG] Event creating-client-class.s3: calling handler &lt;function add_generate_presigned_url at 0x7fa830cbcaf0&gt;
  2022-09-10 17:26:10,424 botocore.endpoint [DEBUG] Setting s3 timeout as (60, 60)
  2022-09-10 17:26:10,424 botocore.loaders [DEBUG] Loading JSON file: /home/.../sam_bucket_fetch/samvenv/lib/python3.8/site-packages/botocore/data/_retry.json
  2022-09-10 17:26:10,424 botocore.client [DEBUG] Registering retry handlers for service: s3
  2022-09-10 17:26:10,425 botocore.hooks [DEBUG] Event before-parameter-build.s3.ListBuckets: calling handler &lt;function validate_bucket_name at 0x7fa830c5cca0&gt;
  2022-09-10 17:26:10,425 botocore.hooks [DEBUG] Event before-parameter-build.s3.ListBuckets: calling handler &lt;bound method S3RegionRedirector.redirect_from_cache of &lt;botocore.utils.S3RegionRedirector object at 0x7fa83039d6a0&gt;&gt;
  2022-09-10 17:26:10,425 botocore.hooks [DEBUG] Event before-parameter-build.s3.ListBuckets: calling handler &lt;bound method S3ArnParamHandler.handle_arn of &lt;botocore.utils.S3ArnParamHandler object at 0x7fa83039d760&gt;&gt;
  2022-09-10 17:26:10,425 botocore.hooks [DEBUG] Event before-parameter-build.s3.ListBuckets: calling handler &lt;function generate_idempotent_uuid at 0x7fa830c5caf0&gt;
  2022-09-10 17:26:10,426 botocore.hooks [DEBUG] Event before-call.s3.ListBuckets: calling handler &lt;function add_expect_header at 0x7fa830c62040&gt;
  2022-09-10 17:26:10,426 botocore.hooks [DEBUG] Event before-call.s3.ListBuckets: calling handler &lt;bound method S3RegionRedirector.set_request_url of &lt;botocore.utils.S3RegionRedirector object at 0x7fa83039d6a0&gt;&gt;
  2022-09-10 17:26:10,426 botocore.hooks [DEBUG] Event before-call.s3.ListBuckets: calling handler &lt;function add_recursion_detection_header at 0x7fa830c5c790&gt;
  2022-09-10 17:26:10,426 botocore.hooks [DEBUG] Event before-call.s3.ListBuckets: calling handler &lt;function inject_api_version_header_if_needed at 0x7fa830c5e3a0&gt;
  2022-09-10 17:26:10,426 botocore.endpoint [DEBUG] Making request for OperationModel(name=ListBuckets) with params: {'url_path': '/', 'query_string': '', 'method': 'GET', 'headers': {'User-Agent': 'Boto3/1.24.69 Python/3.8.10 Linux/5.15.0-46-generic Botocore/1.27.69'}, 'body': b'', 'url': 'http://localhost:4566/', 'context': {'client_region': 'us-east-1', 'client_config': &lt;botocore.config.Config object at 0x7fa830544880&gt;, 'has_streaming_input': False, 'auth_type': None, 'signing': {'bucket': None}}}
  2022-09-10 17:26:10,426 botocore.hooks [DEBUG] Event request-created.s3.ListBuckets: calling handler &lt;bound method RequestSigner.handler of &lt;botocore.signers.RequestSigner object at 0x7fa8305448b0&gt;&gt;
  2022-09-10 17:26:10,426 botocore.hooks [DEBUG] Event choose-signer.s3.ListBuckets: calling handler &lt;bound method S3EndpointSetter.set_signer of &lt;botocore.utils.S3EndpointSetter object at 0x7fa83039d7f0&gt;&gt;
  2022-09-10 17:26:10,426 botocore.hooks [DEBUG] Event choose-signer.s3.ListBuckets: calling handler &lt;bound method ClientCreator._default_s3_presign_to_sigv2 of &lt;botocore.client.ClientCreator object at 0x7fa830b7c9a0&gt;&gt;
  2022-09-10 17:26:10,426 botocore.hooks [DEBUG] Event choose-signer.s3.ListBuckets: calling handler &lt;function set_operation_specific_signer at 0x7fa830c5c9d0&gt;
  2022-09-10 17:26:10,426 botocore.hooks [DEBUG] Event before-sign.s3.ListBuckets: calling handler &lt;bound method S3EndpointSetter.set_endpoint of &lt;botocore.utils.S3EndpointSetter object at 0x7fa83039d7f0&gt;&gt;
  2022-09-10 17:26:10,426 botocore.utils [DEBUG] Using S3 path style addressing.
  2022-09-10 17:26:10,426 botocore.auth [DEBUG] Calculating signature using v4 auth.
  2022-09-10 17:26:10,427 botocore.auth [DEBUG] CanonicalRequest:
  GET
  /
  
  host:localhost:4566
  x-amz-content-sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
  x-amz-date:20220910T152610Z
  
  host;x-amz-content-sha256;x-amz-date
  e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
  2022-09-10 17:26:10,427 botocore.auth [DEBUG] StringToSign:
  AWS4-HMAC-SHA256
  20220910T152610Z
  20220910/us-east-1/s3/aws4_request
  d92a569143f1a1e667c82b75387a5c934a1827c0fe066ad45d5456e68e611c0f
  2022-09-10 17:26:10,427 botocore.auth [DEBUG] Signature:
  cc00ece2c2d811961014abd7d8d94d89bf00bf79451984ed4d441d02f23aff74
  2022-09-10 17:26:10,427 botocore.hooks [DEBUG] Event request-created.s3.ListBuckets: calling handler &lt;function add_retry_headers at 0x7fa830c5ea60&gt;
  2022-09-10 17:26:10,427 botocore.endpoint [DEBUG] Sending http request: &lt;AWSPreparedRequest stream_output=False, method=GET, url=http://localhost:4566/, headers={'User-Agent': b'Boto3/1.24.69 Python/3.8.10 Linux/5.15.0-46-generic Botocore/1.27.69', 'X-Amz-Date': b'20220910T152610Z', 'X-Amz-Content-SHA256': b'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'Authorization': b'AWS4-HMAC-SHA256 Credential=test/20220910/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date, Signature=cc00ece2c2d811961014abd7d8d94d89bf00bf79451984ed4d441d02f23aff74', 'amz-sdk-invocation-id': b'bc337f23-16ed-45b4-a4fc-35ef791b8ca8', 'amz-sdk-request': b'attempt=1'}&gt;
  2022-09-10 17:26:10,427 urllib3.connectionpool [DEBUG] Starting new HTTP connection (1): localhost:4566
  2022-09-10 17:26:10,437 urllib3.connectionpool [DEBUG] http://localhost:4566 &quot;GET / HTTP/1.1&quot; 200 None
  2022-09-10 17:26:10,437 botocore.parsers [DEBUG] Response headers: {'Content-Type': 'application/xml; charset=utf-8', 'Server': 'Werkzeug/2.1.2 Python/3.10.6, hypercorn-h11', 'Date': 'Sat, 10 Sep 2022 15:26:10 GMT, Sat, 10 Sep 2022 15:26:10 GMT', 'x-amzn-requestid': 'OOV6T6D0GMR5UGEOFRVJZT7M4HERBJIRJU7KNCFOK8MA8W6WS6O3', 'Access-Control-Allow-Origin': '*', 'Connection': 'close', 'Last-Modified': 'Sat, 10 Sep 2022 15:26:10 GMT', 'x-amz-request-id': 'C1AC97638736B0D5', 'x-amz-id-2': 'MzRISOwyjmnupC1AC97638736B0D57/JypPGXLh0OVFGcJaaO3KW/hRAqKOpIEEp', 'accept-ranges': 'bytes', 'content-language': 'en-US', 'Transfer-Encoding': 'chunked'}
  2022-09-10 17:26:10,437 botocore.parsers [DEBUG] Response body:
  b'&lt;ListAllMyBucketsResult xmlns=&quot;http://s3.amazonaws.com/doc/2006-03-01&quot;&gt;&lt;Owner&gt;&lt;ID&gt;bcaf1ffd86f41161ca5fb16fd081034f&lt;/ID&gt;&lt;DisplayName&gt;webfile&lt;/DisplayName&gt;&lt;/Owner&gt;&lt;Buckets&gt;&lt;Bucket&gt;&lt;Name&gt;mybucket&lt;/Name&gt;&lt;CreationDate&gt;2022-09-10T10:46:41.000Z&lt;/CreationDate&gt;&lt;/Bucket&gt;&lt;/Buckets&gt;&lt;/ListAllMyBucketsResult&gt;'
  2022-09-10 17:26:10,438 botocore.hooks [DEBUG] Event needs-retry.s3.ListBuckets: calling handler &lt;botocore.retryhandler.RetryHandler object at 0x7fa83039d640&gt;
  2022-09-10 17:26:10,438 botocore.retryhandler [DEBUG] No retry needed.
  2022-09-10 17:26:10,438 botocore.hooks [DEBUG] Event needs-retry.s3.ListBuckets: calling handler &lt;bound method S3RegionRedirector.redirect_from_error of &lt;botocore.utils.S3RegionRedirector object at 0x7fa83039d6a0&gt;&gt;
  </code></pre>