0

I wish to execute code that runs like the lambda.invoke function from https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html. e.g.

import AWS from 'aws-sdk'
var lambda = new AWS.Lambda()
var params = {
FunctionName: func,
InvocationType: "Event",
Payload: obj
}
await lambda.invoke(params).promise()

However, this is from an older version (v2) and I wish to achieve the same result using the javascript aws-sdk v3. I am looking at the documentation at https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-lambda/index.html, but I can't find out which function will let me achieve the same result. Would anyone know how to achieve the same invocation of the lambda in a 'fire and forget' manner?

1 Answer 1

4

The following snippet is taken from the official documentation and extended with a example for the required input. Please be sure to study the documentation for further information.

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

const client = new LambdaClient();

// see: https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-lambda/interfaces/invokecommandinput.html
const input = {
  FunctionName: "",
  InvocationType: "",
  LogType: "",
  Payload: "",
  Qualifier: ""
}

const command = new InvokeCommand(input);
const response = await client.send(command);

Documentation: https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-lambda/classes/invokecommand.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.