【发布时间】:2021-07-25 20:41:05
【问题描述】:
我正在我的 AWS Lambda 中导入“ping”npm 模块并尝试运行该函数以进行 ping 探测。
pingRegion = async (region) => {
let res = await ping.promise.probe(`dynamodb.${region}.amazonaws.com`);
console.log('ping response time ',res.time);
}
node_modules 结构导入正常,不存在文件级权限或路径问题。
但是当我测试 lambda 时,我看到了这个 promise 错误。如何授予我的 lambda 权限以执行此操作?感谢您提前提供的任何支持。
Unhandled Promise Rejection {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"Error: ping.probe: there was an error while execution the ping program.. Check the path or permissions...","原因":{"errorType":"Error","errorMessage":"ping.probe: 执行 ping 程序时出错。检查路径或权限...","stack":["错误: ping.probe: 执行 ping 程序时出错。检查路径或权限..."," 在 ChildProcess. (/var/task/node_modules/ping/lib/ping-promise.js:61:19 )"," 在 Object.onceWrapper (events.js:421:26)"," 在 ChildProcess.emit (events.js:314:20)"," 在 ChildProcess.EventEmitter.emit (domain.js:483:12 )"," 在 Process.ChildProcess._handle.onexit (internal/child_process.js:274:12)"," 在 onErrorNT (internal/child_process.js:470:16)"," 在 processTicksAndRejections (internal/process/task_queues .js:84:21)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: 错误: ping.probe: 有执行 ping 程序时出错。 .检查路径或权限..."," 在进程中。 (/var/runtime/index.js:35:15)","在 process.emit (events.js:314:20)","在 process.EventEmitter.emit (domain.js:483:12)", "在 processPromiseRejections (internal/process/promises.js:209:33)"," 在 processTicksAndRejections (internal/process/task_queues.js:98:32)"]}
【问题讨论】:
-
遇到同样的问题
标签: node.js amazon-web-services npm aws-lambda ping