2024 answer using aws sdk for javascript v3
AWS announced end of support for aws sdk v3 effective September 8 2025 - reference here.
You can invoke a 2nd lambda function from your lambda using the following:
const { InvokeCommand, LambdaClient, LogType } = require("@aws-sdk/client-lambda"); // import {InvokeCommand, LambdaClient, LogType} from "@aws-sdk/client-lambda"; const client = new LambdaClient({ region: "eu-west-2" }); // replace with your region const command = new InvokeCommand({ FunctionName: "my-second-lambda", // replace with your function name Payload: JSON.stringify(payload), // replace with your stringified payload LogType: LogType.Tail, }); const { Payload, LogResult } = await client.send(command); const result = Buffer.from(Payload).toString(); const logs = Buffer.from(LogResult, "base64").toString();
Note that this is a synchronous call where the first lambda will wait for the 2nd lambda's response before exiting. For asynchronous calls, where the first lambda fires and forgets add InvocationType: 'Event' to the command.
const command = new InvokeCommand({ FunctionName: "my-second-lambda", Payload: JSON.stringify(payload), LogType: LogType.Tail, InvocationType: 'Event' // for calling the 2nd lambda asynchronously });
Reference here - https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/javascript_lambda_code_examples.html