I have successfully invoked a lambda function from within my node file. It returns 200 and success, but I need to pass in a value to the function I am calling and am unsure how to do that. I am beginning to learn lambda and believe I am not understanding correctly how some things operate. I am attempting to pass in an email address to the lambda function.
function callLambda(){
var AWS = require('aws-sdk');
AWS.config.region = 'us-west-2'
var lambda = new AWS.Lambda();
var params = {
FunctionName: 'UploadDailyRecords',
Payload: '{"client_id" : "[email protected]"}'
};
lambda.invoke(params, function(err, data) {
if (err) console.log(err, err.stack);
else console.log(data);
});
}
callLambda();
Also, I am unsure of the correct format of how to invoke it from the other function to accept a variable from this invocation. This is the way the invoked lambda is set up on AWS.
exports.handler = function(event, context, callback) {
get_clients_email();
callback(null, "completed");
}
Thanks for any help.
When you invoke a function, you can choose to invoke it synchronously or asynchronously. With synchronous invocation, you wait for the function to process the event and return a response. With asynchronous invocation, Lambda queues the event for processing and returns a response immediately.
Everything looks good, you just need to access the payload parameter in your Lambda function now via event.client_id
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With