![](/img/trans.png)
[英]AWS Lambda Function is returning "Cannot find module 'index'" yet the handler in the config is set to index
[英]AWS Lambda using Image Container cannot find handler export
使用無服務器 AWS Lambda 圖像容器,但找不到處理程序。
無服務器迫使我:
service: example-service
provider:
name: aws
ecr:
images:
appimage:
path: ./
file: Dockerfile
platform: linux/arm64
functions:
getDocument:
image:
command:
- src/function/getDocument/index.handler
entryPoint:
- '/lambda-entrypoint.sh'
name: appimage
FROM public.ecr.aws/lambda/nodejs:12
COPY src/function/getDocument/index.ts ./
CMD ["index.handler"]
"errorType":"Runtime.HandlerNotFound",
"errorMessage":"src/function/getDocument/index.handler is undefined or not exported",
"stack":["Runtime.HandlerNotFound: index.handler is undefined or not exported", "at Object.module.exports.load (/var/runtime/UserFunction.js:144:11)"
我不確定 UserFunction.js 是如何適應這個的。
這是我使用 webpack 的獨特設置的解決方案。
我需要
service: example-service
provider:
name: aws
ecr:
images:
appimage:
path: ./
file: Dockerfile
platform: linux/arm64
functions:
getDocument:
image:
command:
- src/function/getDocument/index.handler
entryPoint:
- '/lambda-entrypoint.sh'
name: appimage
FROM public.ecr.aws/lambda/nodejs:14
RUN yum -y upgrade
RUN yum -y install YOUR_PACKAGES
COPY build/getDocument/index.js build/getDocument/index.js.map ${LAMBDA_TASK_ROOT}
RUN npm add text2png
CMD ["index.handler"]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.