Cant invoke lambda from other lambda

Hi i`m trying to call another lambda from within a lambda. I always get the error
“The request processing has failed because of an unknown error, exception or failure.” (statuscode: 500).
This is my calling lambda:


export const saleOrderProcessingHandler: APIGatewayProxyHandler = async (
  event,
): Promise<APIGatewayProxyResult> => {
  console.log("!!!!!!! saleOrderProcessingHandler");
  let response;
  const requestData = JSON.parse(event.body);

  const lambda = new AWS.Lambda({
    region: "eu-west-1",
  });

  const sampleData = { number1: 1, number: 2 };

  const params = {
    FunctionName: "serverless-dev-child_lambda",
    Payload: JSON.stringify(sampleData),
  };

  try {
    await lambda.invoke(params, (res) => {
      console.log(res);
    });
  } catch (e) {
    console.log("invokeLambda :: Error: " + e);
  }

and this is the setup:

  child_lambda: {
    handler: "handler.mainHandler",
  },
  saleOrderProcessingAction: {
    handler: "handler.saleOrderProcessingAction",
    events: [
      {
        http: {
          method: "post",
          path: "saleOrderProcessing",
        },
      },
    ],
  },

!! Even when i change the name of the invoked lambda to child_lambda, it doesn`t work.
I also added IAM permissions

 {
        Effect: "Allow",
        Action: ["lambda:InvokeFunction", "lambda:InvokeAsync"],
        Resource: "*",
      },

Based on the documentation it looks like you are invoking the lambda correctly. It is how I do it as well. When setting the FunctionName parameter make sure it matches exactly to the name of the lambda as deployed in AWS not as named in the serverless template.

In this case I would look closer at the logs for the calling lambda to be sure it is failing where you think it is failing. The 500 HTTP response just indicates the lambda failed. It could be on any part of the code. So review the lambda logs for detail on where it might be failing.