How to invoke Lambda function using AWS-SDK V3 for Javascript / Typescript

import { InvokeCommand, LambdaClient, LogType } from "@aws-sdk/client-lambda";

async function main() {
  const client = new LambdaClient({ region: "us-east-1" });
  const command = new InvokeCommand({
    FunctionName: "my-function-name",
    Payload: JSON.stringify({ key: "value" }),
    LogType: LogType.Tail, // Tail | None
  });

  const { Payload, LogResult } = await client.send(command);

  // Decode invocation result
  const result = Buffer.from(Payload).toString();

  // Decode the log result
  const logs = Buffer.from(LogResult, "base64").toString();

  return { logs, result };
}

console.log(main());
22 lines of code, 617 characters

Similar AWS code snippets using javascript

Finally, a good search for AWS Console

Was that in us-east-1? Or us-west-2? No need to remember. Just type the name of the resource and CloudTempo will find it.

Feature