【发布时间】:2019-11-20 14:40:56
【问题描述】:
从今天开始几个小时,Lambda 上的一个简单 curl 命令失败了。
Lambda环境是NodeJs 10.x(12.x也试过)。
const { execSync } = require('child_process');
exports.handler = async (event) => {
execSync('curl http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg -o /tmp/BigBuckBunny.jpg');
const response = {
statusCode: 200,
body: JSON.stringify('Hello from Lambda!'),
};
return response;
};
我收到 /bin/sh curl: command not found 错误 知道问题是什么吗?
Response:
{
"errorType": "Error",
"errorMessage": "Command failed: curl http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg -o /tmBigBuckBunny.jpg\n/bin/sh: curl: command not found\n",
"trace": [
"Error: Command failed: curl http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg -o /tmBigBuckBunny.jpg",
"/bin/sh: curl: command not found",
"",
" at checkExecSyncError (child_process.js:621:11)",
" at execSync (child_process.js:657:15)",
" at Runtime.exports.handler (/var/task/index.js:11:4)",
" at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)"
]
}
【问题讨论】:
-
:) 谢谢。只是这是在之前工作的 AWS Lambda 上。
-
糟糕,AWS 确实使事情变得混乱,但这只是意味着您的
$PATH变量没有按照应有的方式设置。也许您可以将/usr/bin/curl添加到cmd? (或正确的完整路径)?删除之前的评论。祝你好运。 (一如既往;-))。 -
curl 是否已被移除或移至 Lambda 中的新位置? /usr/bin 没有 curl。
标签: curl aws-lambda