title: Serverless Localstack lambda functions send requests to AWS when endpoints are specified
body: <p>I have a pretty normal localstack setup, with this part in the <code>docker-compose.yml</code> file</p>
  <pre class="lang-yaml prettyprint-override"><code>  localstack:
      container_name: &quot;localstack&quot;
      image: localstack/localstack
      hostname: localstack
      networks:
        - ms-estates
      ports:
        - &quot;127.0.0.1:53:53&quot;
        - &quot;127.0.0.1:53:53/udp&quot;
        - &quot;127.0.0.1:443:443&quot;
        - &quot;127.0.0.1:4566:4566&quot;
        - &quot;127.0.0.1:4571:4571&quot;
      environment:
        - AWS_DEFAULT_REGION=eu-central-1
        - SERVICES=apigateway,lambda,sqs,secretsmanager,s3,cloudformation,sts,iam,route53
        - DEBUG=1
  #      - LAMBDA_EXECUTOR=docker-reuse
        - LAMBDA_REMOTE_DOCKER=false
        - LAMBDA_REMOVE_CONTAINERS=true
        - LAMBDA_DOCKER_NETWORK=ms-estates
        - AWS_XRAY_SDK_ENABLED=true
        - DOCKER_HOST=unix:///var/run/docker.sock
        - DATA_DIR=/tmp/localstack/data
        - START_WEB=1
        - HOSTNAME_EXTERNAL=localstack
      volumes:
        - '/var/run/docker.sock:/var/run/docker.sock'
        - &quot;${TMPDIR:-/tmp/localstack}:/tmp/localstack&quot;
        - ./localstack:/docker-entrypoint-initaws.d
  </code></pre>
  <p>and this is the serverless-localstack part I have in the <code>serverless.yml</code> file:</p>
  <pre class="lang-yaml prettyprint-override"><code>custom:
    localstack:
      stages:
        - local
      lambda:
        mountCode: True
  #    endpointFile: localstack_endpoints.json
      endpoints:
        SecretsManager: http://localstack:4566
        secretsmanager: http://localstack:4566
  </code></pre>
  <p>You see I even tried different cases and <code>endpointsFile</code> property with the same result.</p>
  <p>The problem I'm having is that when I try to connect to the Secrets Manager (or any other service) my code is still trying to knock to the AWS service</p>
  <pre class="lang-typescript prettyprint-override"><code>  constructor() {
      this.secretsManager = new SecretsManager();
    }
  </code></pre>
  <p>This part is going to try to reach this URL <code>secretsmanager.eu-central-1.amazonaws.com</code></p>
  <p>How can I make my code talk to the local service instances without “if env” hacks?</p>