【发布时间】:2018-02-16 09:46:33
【问题描述】:
要在我的 EC2 实例中执行 Node 命令,我只需在 CLI 中使用以下命令
gsjson 1KIg84G9CXErw2bWhkEHWUkOI4CR-biFeLqCtdypaLU8 fruits.json
当我尝试在打包的 AWS Lambda 函数中执行此操作时,它不起作用。这是我的 Node AWS Lambda 代码:
var gsjson = require('google-spreadsheet');
var fs = require('fs');
exports.handler = function(event, context) {
// Create JSON file from Google Sheet using gsjson
gsjson 1KIg84G9CXErw2bWhkEHWUkOI4CR-biFeLqCtdypaLU8 fruits.json {
if (err) {
context.fail("JSON file creation error: " + err);
} else {
context.succeed("JSON file created");
}
});
//Read the content from the /tmp directory to check the JSON file exists
fs.readdir("/tmp", function (err, data) {
console.log(data);
});
}
如何像在 EC2 CLI 中但在 AWS Lambda 函数中一样执行 Node 命令?
【问题讨论】:
标签: javascript node.js amazon-web-services amazon-ec2 aws-lambda