简体   繁体   English

Aws将值从Lambda触发器传递到步进功能

[英]Aws Pass Value from Lambda Trigger to Step Function

使用Lambda函数触发步进函数时,如何获取触发它的函数的输出?

Ok, so if you want to pass an input to a Step Function execution (or, more exactly, your 'State Machine' 's execution), you just need to set said input the input property when calling StartExecution (see AWS Documentation: Start Execution ) 好的,因此,如果您要将输入传递给Step Function执行(或更确切地说,是“状态机 ”的执行),则只需在调用StartExecution时将所述输入设置为input属性(请参阅AWS文档:开始)。执行

In your case, it would most likely be your lambda's last step before calling it's callback. 在您的情况下,很可能是lambda在调用它的回调之前的最后一步。

If it's a node js lambda, that's what it would look like 如果它是一个节点js lambda,那就是它的样子

const AWS = require("aws-sdk");
const stepfunctions = new AWS.StepFunctions();

exports.myHandler = function(event, context, callback) {

    ... your function's code

    const params = {
       stateMachineArn: 'YOUR_STATE_MACHINE_ARN', /* required */
       input: 'STRINGIFIED INPUT',
       name: 'AN EXECUTION NAME (such as an uuid or whatever)'
    };
    stepfunctions.startExecution(params, function(err, data) {
       if (err) callback(err); // an error occurred
       else     callback(null, "some success message"); // successful response
    });

}

Alternatively, if your payload is too big, you could store the data in S3 or DynamoDB and pass the reference to it as your State Machine's execution's input. 或者,如果您的有效负载太大,则可以将数据存储在S3或DynamoDB中,并将对它的引用作为状态机执行的输入传递。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM