title: Getting "Could not connect to the endpoint URL" Error with boto3 when deploying in Localstack
body: <p>I am using Localstack to test my changes in local. My lambda function is supposed to perform putObject and create object in the s3 bucket. The functionality works fine when directly tested with AWS environment. But in Localstack, its not working. I get the below error. </p>
  
  <blockquote>
    <p>Could not connect to the endpoint URL:
    "<a href="http://localhost:4572/doyouknowme/pokemon.jpeg" rel="noreferrer">http://localhost:4572/doyouknowme/pokemon.jpeg</a>"
        raise EndpointConnectionError(endpoint_url=request.url, error=e)ponset_exceptionlhost:4572/doyouknowme/pokemon.jpeg"</p>
  </blockquote>
  
  <p>AWS Credentials:</p>
  
  <pre><code>[default]
  aws_access_key_id = AKI****************
  aws_secret_access_key = gL************************
  region = us-east-1
  </code></pre>
  
  <p>Lambda function code:</p>
  
  <pre><code>import json
  import urllib.parse
  import boto3
  import base64
  
  print('Loading function')
  # session = boto3.Session(profile_name='personal')
  # s3 = session.client('s3', endpoint_url='http://localhost:4574')
  
  s3 = boto3.client('s3', endpoint_url='http://localhost:4572', region_name='us-east-1')
  
  
  def lambda_handler(event, context):
      # raise Exception('Something went wrong')
      print("Received event: " + json.dumps(event, indent=2))
  
  
      try:
          image_data = base64.b64decode(event['image_data'])
          response = s3.put_object(
              Body=image_data,
              Bucket='doyouknowme',
              Key='pokemon.jpeg',
              ContentType='image/jpeg'
          )
  
          print(response)
          return response
  
      except Exception as e:
          print(e)
          # print(
          #     'Error getting object {} from bucket {}. Make sure they exist and your bucket is in the same region as '
          #     'this function.'.format(
          #         key, bucket))
          raise e
  </code></pre>
  
  <p>I am not sure why the s3 key got appended to the endpoint URL which is accessed by lambda. 
  Appreciate your help to resolve this.</p>