'simplest hello world AWS Lambda runing nodejs failing /var/runtime/Runtime.js:67:14
I have very little experience on this stack and I've tried several google searches. I didn't find anything!
I'm trying to build a function as simple as possible. A "hello world" style, without compiling the docker container;
This is what I have done ...
docker-compose.yml
version: '3.7'
volumes:
lambda-node:
driver: local
services:
lambda-node:
image: amazon/aws-lambda-nodejs:12
environment:
- STAGE=${STAGE:-local}
ports:
- 9000:8080
volumes:
- ./src/node:/var/task
command:
- app.handler
./src/node/app.js
exports.handler = async (event, context) => {
console.log(event);
console.log(context);
return "{\"message\": \"Hello World.\"}";
}
./src/node/package.json
{
"name": "node",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
PS: I tried:
- Multiple return options, using or not using JSON.stringify and several other attempts, so I don't believe it's the return itself. To me it seams the script is not event been loaded;
- Generate a package-lock.json
- I started using TAG 14.2022.02.01.09 then I started using TAG 14 and finally I'm doing tests with TAG 10. They all generate the same result
- I even try to run the script as a module!
The output
$ docker-compose up
Starting magma_lambda-node_1 ... done
Attaching to magma_lambda-node_1
lambda-node_1 | 22 Feb 2022 12:20:09,249 [INFO] (rapid) exec '/var/runtime/bootstrap' (cwd=/var/task, handler=)
lambda-node_1 | 22 Feb 2022 12:20:16,280 [INFO] (rapid) extensionsDisabledByLayer(/opt/disable-extensions-jwigqn8j) -> stat /opt/disable-extensions-jwigqn8j: no such file or directory
lambda-node_1 | 22 Feb 2022 12:20:16,280 [WARNING] (rapid) Cannot list external agents error=open /opt/extensions: no such file or directory
lambda-node_1 | START RequestId: e9449065-e27d-444a-b5f0-200ed50bb9b8 Version: $LATEST
lambda-node_1 | 2022-02-22T12:20:16.432Z e9449065-e27d-444a-b5f0-200ed50bb9b8 ERROR Invoke Error {"errorType":"SyntaxError","errorMessage":"Unexpected end of JSON input","stack":["SyntaxError: Unexpected end of JSON input"," at JSON.parse (<anonymous>)"," at Runtime.handleOnce (/var/runtime/Runtime.js:67:14)"]}
lambda-node_1 | END RequestId: e9449065-e27d-444a-b5f0-200ed50bb9b8
lambda-node_1 | REPORT RequestId: e9449065-e27d-444a-b5f0-200ed50bb9b8 Init Duration: 0.35 ms Duration: 160.00 ms Billed Duration: 161 ms Memory Size: 3008 MB Max Memory Used: 3008 MB
Sorry advance for the words! But dud, am I disappointed ...
Can anybody tell me what on earth am I doing wrong?
Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|