AWS Lambda函数可以调用另一个 [英] Can an AWS Lambda function call another

查看:315
本文介绍了AWS Lambda函数可以调用另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个Lambda函数-一个产生报价,另一个将报价变成订单. 我希望Order lambda函数调用Quote函数来重新生成报价,而不是仅仅从不受信任的客户端接收报价.

I have 2 Lambda functions - one that produces a quote and one that turns a quote into an order. I'd like the Order lambda function to call the Quote function to regenerate the quote, rather than just receive it from an untrusted client.

我到处都可以想到的地方-但是看不到如何链接或调用函数...肯定存在!

I've looked everywhere I can think of - but can't see how I'd go about chaining or calling the functions...surely this exists!

推荐答案

我找到了使用aws-sdk的方法.

var aws = require('aws-sdk');
var lambda = new aws.Lambda({
  region: 'us-west-2' //change to your region
});

lambda.invoke({
  FunctionName: 'name_of_your_lambda_function',
  Payload: JSON.stringify(event, null, 2) // pass params
}, function(error, data) {
  if (error) {
    context.done('error', error);
  }
  if(data.Payload){
   context.succeed(data.Payload)
  }
});

您可以在此处找到该文档: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html

You can find the doc here: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html

这篇关于AWS Lambda函数可以调用另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆