= AWS Lambda - Invoke new Lambda =
**Summary**: How to use a lambda to invoke a new lambda \\
**Date**: Around 2022 \\
**Refactor**: 20 February 2025: Checked links and formatting. \\
{{tag>aws lambda nodejs}}
It would be better to do this using [[awstoolkitforvsc|Step Functions]] but sometimes quick and dirty is good enough. See the code below to invoke a new Lambda function onze your current one is done.
// Lambda Variables
var aws = require('aws-sdk');
var lambda = new aws.Lambda({
region: 'eu-west-1' //change to your region
});
// Invoke nextlambda if you don't want to use Step Functions
// function invoke Email
function invokeLambdaEmail(requestBody, callback, error){
var params = {
FunctionName: 'sendoutEmail',
InvocationType: 'Event',
Payload: JSON.stringify(requestBody, null, 2)
};
lambda.invoke(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
}
//This wiki has been made possible by://