localstack / localstack

💻 A fully functional local AWS cloud stack. Develop and test your cloud & Serverless apps offline
https://localstack.cloud
Other
55.65k stars 3.97k forks source link

bug: Getting 500 (ServiceException) when trying to invoke lambda #11613

Open axlb-mpya opened 2 hours ago

axlb-mpya commented 2 hours ago

Is there an existing issue for this?

Current Behavior

When invoking lambda using awslocal I get following problem: localstack_main | 2024-10-01T08:08:56.383 INFO --- [et.reactor-0] localstack.request.aws : AWS lambda.Invoke => 500 (ServiceException)

Function is created successfully when checking logs and I can see it in LocalStack GUI.

Function code:

exports.handler = async (event) => {
    console.log(event);
    const response = {
        statusCode: 200,
        body: "ok",
    };
    return response;
};

docker-compose.yml

version: "3.8"

services:
  localstack:
    container_name: "${LOCALSTACK_DOCKER_NAME-localstack_main}"
    image: localstack/localstack:latest
    ports:
      - "127.0.0.1:4566:4566"            # LocalStack Gateway
      - "127.0.0.1:4510-4559:4510-4559"  # external services port range
    environment:
      - SERVICES=s3,sns,sqs,lambda,apigateway,cloudwatch,dynamodb,logs
      - DEBUG=1
      - LAMBDA_REMOTE_DOCKER=0
      - LAMBDA_DOCKER_FLAGS=-e NODE_OPTIONS=--inspect-brk=0.0.0.0:9229 -p 9229:9229
      - LAMBDA_EXECUTOR=${LAMBDA_EXECUTOR-}
      - DOCKER_HOST=unix:///var/run/docker.sock
    volumes:
      - "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"

See "Steps to reproduce"

Expected Behavior

Expecting a 200 sucessful invocation

How are you starting LocalStack?

With a docker-compose file

Steps To Reproduce

How are you starting localstack (e.g., bin/localstack command, arguments, or docker-compose.yml)

docker compose up

Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)

awslocal lambda create-function \
   --function-name function-handler \
   --code S3Bucket="hot-reload",S3Key="$(pwd)" \
   --handler function.handler \
   --runtime nodejs18.x \
   --timeout 120 \
   --role arn:aws:iam::000000000000:role/lambda-role
awslocal lambda invoke --function-name function-handler \
   --cli-binary-format raw-in-base64-out \
   --payload '{"hello":"world"}' \
   output.txt

Environment

(NOTE: I'm using WSL2 on windows machine)

- OS:Ubuntu 22.04.3 LTS

- LocalStack version: 3.7.3.dev56
LocalStack build date: 2024-09-27
LocalStack build git hash: 9b3530f8d

Anything else?

No response

localstack-bot commented 2 hours ago

Welcome to LocalStack! Thanks for reporting your first issue and our team will be working towards fixing the issue for you or reach out for more background information. We recommend joining our Slack Community for real-time help and drop a message to LocalStack Pro Support if you are a Pro user! If you are willing to contribute towards fixing this issue, please have a look at our contributing guidelines and our contributing guide.