{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module 'athena-express'\\nRequire stack:\\n- /var/task/index.js\\n- /var/runtime/index.mjs",
"trace": [
"Runtime.ImportModuleError: Error: Cannot find module 'athena-express'",
"Require stack:",
"- /var/task/index.js",
"- /var/runtime/index.mjs",
" at _loadUserApp (file:///var/runtime/index.mjs:726:17)",
" at async Object.module.exports.load (file:///var/runtime/index.mjs:741:21)",
" at async file:///var/runtime/index.mjs:781:15",
" at async file:///var/runtime/index.mjs:4:1"
]
}
람다 코드를 실행하는데 필요한 라이브러리가 설치된 런타임이 없다는 오류이다.
여기에서는 athena-express 가 설치되지 않았다.
해결책으로는 Lambda용 Node.js 코드에서 사용할 라이브러리가 포함된 배포 패키지 또는 Lambda 계층을 생성하면 된다.
$ curl -o- <https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh> | bash
$ . ~/.nvm/nvm.sh
$ nvm install node
$ mkdir nodejs
$ cd nodejs
$ npm init
$ npm install --save athena-express
$ cd ../
$ zip -r layer.zip nodejs
$ aws lambda publish-layer-version --layer-name athena --zip-file fileb://layer.zip --compatible-runtimes nodejs12.x --region ap-northeast-2