可以在AWS Lambda函数中编写bash脚本吗 [英] Can bash script be written inside a AWS Lambda function
问题描述
我可以在Lambda函数中编写bash脚本吗?我在aws文档中读到,它可以执行用Python,NodeJS和Java 8编写的代码.
Can I write a bash script inside a Lambda function? I read in the aws docs that it can execute code written in Python, NodeJS and Java 8.
在某些文档中提到可能可以使用Bash,但没有具体证据支持它或任何示例
It is mentioned in some documents that it might be possible to use Bash but there is no concrete evidence supporting it or any example
推荐答案
这可能有所帮助,我正在使用Node调用bash脚本.我使用以下代码作为处理程序,将脚本和nodejs文件以zip格式上传到了lambda.
Something that might help, I'm using Node to call the bash script. I uploaded the script and the nodejs file in a zip to lambda, using the following code as the handler.
exports.myHandler = function(event, context, callback) {
const execFile = require('child_process').execFile;
execFile('./test.sh', (error, stdout, stderr) => {
if (error) {
callback(error);
}
callback(null, stdout);
});
}
您可以使用回调函数返回所需的数据.
You can use the callback to return the data you need.
这篇关于可以在AWS Lambda函数中编写bash脚本吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!