admin管理员组

文章数量:1278786

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, "pleted");
}

Thanks for any help.

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, "pleted");
}

Thanks for any help.

Share Improve this question edited Apr 12, 2017 at 17:04 Mike asked Apr 12, 2017 at 14:59 MikeMike 3282 gold badges4 silver badges13 bronze badges 1
  • What did the final solution look like here? How would it work if I need to pass to attributes in the Payload object? – lopezdp Commented Aug 13, 2020 at 14:18
Add a ment  | 

1 Answer 1

Reset to default 9

Everything looks good, you just need to access the payload parameter in your Lambda function now via event.client_id.

本文标签: javascriptPassing in value to an invoked lambda function from nodejs functionStack Overflow