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: "*",
},