After successfully deploying my stack using serverless deploy, my lambda functions fail, citing a module import error Runtime.ImportModuleError.
Because I need binaries built specifically for linux, the packaging and deployment takes place inside a docker container, the docker file is as follows:
FROM lambci/lambda:build-nodejs10.x
ENV AWS_DEFAULT_REGION XXXX
ENV SERVERLESS_ACCESS_KEY XXXXXXXXXXXXXXXX
ENV AWS_ACCESS_KEY_ID XXXXXXXXXXXX
ENV AWS_SECRET_ACCESS_KEY XXXXXXXXXXXXXXX
RUN npm install -g serverless
WORKDIR /usr/src/app
COPY . .
RUN rm -rf node_modules
RUN npm install
CMD serverless deploy
The lambdaβs stack trace is as follows:
{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module 's-fetchUserData'",
"trace": [
"Runtime.ImportModuleError: Error: Cannot find module 's-fetchUserData'",
" at _loadUserApp (/var/runtime/UserFunction.js:100:13)",
" at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
" at Object.<anonymous> (/var/runtime/index.js:36:30)",
" at Module._compile (internal/modules/cjs/loader.js:776:30)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)",
" at Module.load (internal/modules/cjs/loader.js:653:32)",
" at tryModuleLoad (internal/modules/cjs/loader.js:593:12)",
" at Function.Module._load (internal/modules/cjs/loader.js:585:3)",
" at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)",
" at startup (internal/bootstrap/node.js:283:19)"
]
}
If I download the .zip file from s3 for the deployment, I can see the s_fetchUserData.js file in the root of the project.
Hereβs the file tree:
.
βββ Dockerfile
βββ NOTES.md
βββ README.md
βββ docker-compose.yml
βββ package-lock.json
βββ package.json
βββ s_fetchUserData.js
βββ s_generateEmail.js
βββ s_processGif.js
βββ s_processPhoto.js
βββ s_processTimelapseVideo.js
βββ s_startExecution.js
βββ serverless_sdk
β βββ index.js
βββ src
βββ handlers
β βββ email
β β βββ handler.js
β β βββ mira.code-workspace
β βββ image-processing
β β βββ gif
β β β βββ handler.js
β β βββ photo
β β βββ handler.js
β βββ start
β β βββ handler.js
β βββ test
β β βββ handler.js
β βββ timelapse
β β βββ handler.js
β βββ upload
β β βββ handler.js
β βββ user
β β βββ handler.js
β βββ video
β βββ timelapse
β βββ handler.js
βββ templates
β βββ email
β βββ content.pug
βββ test
β βββ email.json
β βββ index.html
β βββ locationData.json
β βββ processImage.json
β βββ pugRenderer.js
β βββ timelapse.json
β βββ timelapseVideo.json
β βββ user.json
β βββ views
β βββ email-bg.svg
β βββ index.pug
βββ utils
βββ index.js
19 directories, 35 files