title: UnrecognizedClientException when invoking a lambda from another lambda using localstack
body: <p>I am running localstack inside of a docker container with this <code>docker-compose.yml</code> file.</p>
  
  <pre><code>version: '2.1'
  
  services:
    localstack:
      image: localstack/localstack
      ports:
        - "4567-4597:4567-4597"
        - "${PORT_WEB_UI-8080}:${PORT_WEB_UI-8080}"
      environment:
        - SERVICES=${SERVICES- }
        - DEBUG=1
        - DATA_DIR=${DATA_DIR- }
        - PORT_WEB_UI=${PORT_WEB_UI- }
        - LAMBDA_EXECUTOR=docker
        - KINESIS_ERROR_PROBABILITY=${KINESIS_ERROR_PROBABILITY- }
        - DOCKER_HOST=unix:///var/run/docker.sock
      volumes:
        - "${TMPDIR:-/tmp/localstack}:/tmp/localstack"
        - "/var/run/docker.sock:/var/run/docker.sock"
  </code></pre>
  
  <p>To start localstack I run <code>TMPDIR=/private$TMPDIR docker-compose up</code>.</p>
  
  <p>I have created two lambdas. When I run <code>aws lambda list-functions --endpoint-url http://localhost:4574 --region=us-east-1</code> this is the output.</p>
  
  <pre><code>{
  "Functions": [
      {
          "TracingConfig": {
              "Mode": "PassThrough"
          },
          "Version": "$LATEST",
          "CodeSha256": "qmDiumefhM0UutYv32By67cj24P/NuHIhKHgouPkDBs=",
          "FunctionName": "handler",
          "LastModified": "2019-08-08T17:56:58.277+0000",
          "RevisionId": "ffea379b-4913-420b-9444-f1e5d51b5908",
          "CodeSize": 5640253,
          "FunctionArn": "arn:aws:lambda:us-east-1:000000000000:function:handler",
          "Environment": {
              "Variables": {
                  "DB_NAME": "somedbname",
                  "IS_PRODUCTION": "FALSE",
                  "SERVER": "xxx.xxx.xx.xxx",
                  "DB_PASS": "somepass",
                  "DB_USER": "someuser",
                  "PORT": "someport"
              }
          },
          "Handler": "handler",
          "Role": "r1",
          "Timeout": 3,
          "Runtime": "go1.x",
          "Description": ""
      },
      {
          "TracingConfig": {
              "Mode": "PassThrough"
          },
          "Version": "$LATEST",
          "CodeSha256": "wbT8YzTsYW4sIOAXLtjprrveq5NBMVUaa2srNvwLxM8=",
          "FunctionName": "paymentenginerouter",
          "LastModified": "2019-08-08T18:00:28.923+0000",
          "RevisionId": "bd79cb2e-6531-4987-bdfc-25a5d87e93f4",
          "CodeSize": 6602279,
          "FunctionArn": "arn:aws:lambda:us-east-1:000000000000:function:paymentenginerouter",
          "Environment": {
              "Variables": {
                  "DB_QUERY_LAMBDA": "handler",
                  "AWS_REGION": "us-east-1"
              }
          },
          "Handler": "handler",
          "Role": "r1",
          "Timeout": 3,
          "Runtime": "go1.x",
          "Description": ""
      }
  ]
  </code></pre>
  
  <p>}</p>
  
  <p>Inside the <code>paymentenginerouter</code> code I am attempting to call the <code>handler</code> lambda via:</p>
  
  <pre><code>    lambdaParams := &amp;invoke.InvokeInput{
      FunctionName:   aws.String(os.Getenv("DB_QUERY_LAMBDA")),
      InvocationType: aws.String("RequestResponse"),
      LogType:        aws.String("Tail"),
      Payload:        payload,
  }
  result, err := svc.Invoke(lambdaParams)
  if err != nil {
      resp.StatusCode = 500
      log.Fatal("Error while invoking lambda:\n", err.Error())
  }
  </code></pre>
  
  <p>Where <code>invoke</code> is an import: <code>invoke "github.com/aws/aws-sdk-go/service/lambda"</code></p>
  
  <p>When I run the <code>paymentenginerouter</code> lambda via:</p>
  
  <pre><code>aws lambda invoke --function paymentenginerouter --payload  '{ "body": "{\"id\":\"12\",\"internalZoneCode\":\"xxxxxx\",\"vehicleId\":\"xxxxx\",\"vehicleVrn\":\"vehicleVrn\",\"vehicleVrnState\":\"vehicleVrnState\",\"durationInMinutes\":\"120\",\"verification\":{\"Token\":null,\"lpn\":null,\"ZoneCode\":null,\"IsExtension\":null,\"ParkingActionId\":null},\"selectedBillingMethodId\":\"xxxxxx\",\"startTimeLocal\":\"2019-07-29T11:36:47\",\"stopTimeLocal\":\"2019-07-29T13:36:47\",\"vehicleVin\":null,\"orderId\":\"1\",\"parkingActionType\":\"OnDemand\",\"digitalPayPaymentInfo\":{\"Provider\":\"&lt;string&gt;\",\"ChasePayData\":{\"ConsumerIP\":\"xxxx\",\"DigitalSessionID\":\"xxxx\",\"TransactionReferenceKey\":\"xxxx\"}}}"
  }' --endpoint-url=http://localhost:4574 --region=us-east-1 out --debug
  </code></pre>
  
  <p>I receive this error:</p>
  
  <pre><code>localstack_1  | 2019/08/08 20:02:28 Error while invoking lambda:
  localstack_1  | UnrecognizedClientException: The security token included in the request is invalid.
  localstack_1  |     status code: 403, request id: bd4e3c15-47ae-44a2-ad6a-376d78d8fd92
  </code></pre>
  
  <p><strong>Note</strong></p>
  
  <p>I <em>can</em> run the <code>handler</code> lambda without error by calling it directly through the cli:</p>
  
  <p><code>aws lambda invoke --function handler --payload '{"body": "SELECT TOKEN, NAME, CREATED, ENABLED, TIMESTAMP FROM dbo.PAYMENT_TOKEN WHERE BILLING_METHOD_ID='xxxxxxx'"}' --endpoint-url=http://localhost:4574 --region=us-east-1 out --debug</code></p>
  
  <p>I thought the AWS credentials are setup according the environment variables in localstack but I could be mistaken. Any idea how to get past this problem?</p>
  
  <p>I am quite new to AWS lambdas and an absolute noob when it comes to localstack so please ask for more details if you need them. It's possible I am missing a critical piece of information in my description.</p>