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

查看:38
本文介绍了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 的方法.

I found a way using the 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天全站免登陆