Reputation: 181
I'm trying to test a function on Lambda, but when I test it i get a Runtime.ExitError:
What would be the cause?
{"errorType": "Runtime.ExitError", "errorMessage": "RequestId:
0dfeb7be-012d-43b7-8674-665bfd8b2bc2 Error: Runtime exited with error: exit status 7" }
ask/node_modules/aws-sdk/lib/request.js:364:18)"," at Request.callListeners (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:106:20)"," at Request.emit (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:78:10)","
at Request.emit (/var/task/node_modules/aws-sdk/lib/request.js:683:14)"," at Request.transition (/var/task/node_modules/aws-sdk/lib/request.js:22:10)"," at AcceptorStateMachine.runTo (/var/task/node_modules/aws-sdk/lib/state_machine.js:14:12)"," at /var/task/node_modules/aws-sdk/lib/state_machine.js:26:10"," at Request. (/var/task/node_modules/aws-sdk/lib/request.js:38:9)"],"message":"Could not create table (Meals): User: arn:aws:sts::929545228810:assumed-role/homeAssistTemp-role-rz5qgsmq/homeAssistTemp is not authorized to perform: dynamodb:CreateTable on resource: arn:aws:dynamodb:us-east-2:929545228810:table/Meals","time":"2019-09-26T18:02:51.854Z"} 2019-09-26T18:02:51.931Z e3d534bb-abd8-4b49-a628-2ec5c6193ec1 INFO Uncaught exception: AskSdk.DynamoDbPersistenceAdapter Error: Could not create table (Meals): User: arn:aws:sts::929545228810:assumed-role/homeAssistTemp-role-rz5qgsmq/homeAssistTemp is not authorized to perform: dynamodb:CreateTable on resource: arn:aws:dynamodb:us-east-2:929545228810:table/Meals AskSdk.DynamoDbPersistenceAdapter Error: Could not create table (Meals): User: arn:aws:sts::929545228810:assumed-role/homeAssistTemp-role-rz5qgsmq/homeAssistTemp is not authorized to perform: dynamodb:CreateTable on resource: arn:aws:dynamodb:us-east-2:929545228810:table/Meals at Object.createAskSdkError (/var/task/node_modules/ask-sdk-runtime/dist/util/AskSdkUtils.js:22:17) at Response. (/var/task/node_modules/ask-sdk-dynamodb-persistence-adapter/dist/attributes/persistence/DynamoDbPersistenceAdapter.js:88:42) at Request. (/var/task/node_modules/aws-sdk/lib/request.js:364:18) at Request.callListeners (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:106:20) at Request.emit (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:78:10) at Request.emit (/var/task/node_modules/aws-sdk/lib/request.js:683:14) at Request.transition (/var/task/node_modules/aws-sdk/lib/request.js:22:10) at AcceptorStateMachine.runTo (/var/task/node_modules/aws-sdk/lib/state_machine.js:14:12) at /var/task/node_modules/aws-sdk/lib/state_machine.js:26:10 at Request. (/var/task/node_modules/aws-sdk/lib/request.js:38:9) /var/task/node_modules/ask-sdk-v1adapter/dist/adapter.js:275 throw err; ^AskSdk.DynamoDbPersistenceAdapter Error: Could not create table (Meals): User: arn:aws:sts::929545228810:assumed-role/homeAssistTemp-role-rz5qgsmq/homeAssistTemp is not authorized to perform: dynamodb:CreateTable on resource: arn:aws:dynamodb:us-east-2:929545228810:table/Meals at Object.createAskSdkError (/var/task/node_modules/ask-sdk-runtime/dist/util/AskSdkUtils.js:22:17) at Response. (/var/task/node_modules/ask-sdk-dynamodb-persistence-adapter/dist/attributes/persistence/DynamoDbPersistenceAdapter.js:88:42) at Request. (/var/task/node_modules/aws-sdk/lib/request.js:364:18) at Request.callListeners (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:106:20) at Request.emit (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:78:10) at Request.emit (/var/task/node_modules/aws-sdk/lib/request.js:683:14) at Request.transition (/var/task/node_modules/aws-sdk/lib/request.js:22:10) at AcceptorStateMachine.runTo (/var/task/node_modules/aws-sdk/lib/state_machine.js:14:12) at /var/task/node_modules/aws-sdk/lib/state_machine.js:26:10 at Request. (/var/task/node_modules/aws-sdk/lib/request.js:38:9) END RequestId: e3d534bb-abd8-4b49-a628-2ec5c6193ec1 REPORT RequestId: e3d534bb-abd8-4b49-a628-2ec5c6193ec1 Duration: 1013.44 ms Billed Duration: 1100 ms Memory Size: 128 MB Max Memory Used: 97 MB Init Duration: 513.63 ms RequestId: e3d534bb-abd8-4b49-a628-2ec5c6193ec1 Error: Runtime exited with error: exit status 7 Runtime.ExitError
Upvotes: 16
Views: 53852
Reputation: 27340
I had this error when running a Docker container on Lambda. The problem was the Docker container had $HOME
as /root
but Lambda runs as an unprivileged user, so it had no write access to /root
.
This is important because Lambda uses npx
(which is the same as npm exec
) to start the runtime interface, and the first thing NPM does is look in $HOME/.npm
. So if that folder is not writable, the Lambda will fail to start.
I could see this was the problem because the CloudWatch logs for the Lambda were telling me there was a permissions error on /root/.npm
. It told me to run chmod
to fix it, but even chmod 777
did not work.
The solution in my case was to add the line ENV HOME /tmp
to the Dockerfile, to move the home directory to /tmp
which is writable by the user the Lambda runs as.
Upvotes: 0
Reputation: 81
You can revisit your serverless.yaml file. This could be because of many things but in my case, the lambda handler was not imported correctly in serverless.yaml
Upvotes: 0
Reputation: 1735
In my case, I had a Node.js Lambda with an ENV variable NODE_OPTIONS
requiring a module that was not found -r module
Upvotes: 0
Reputation: 888
Looks like permissions to me:
Could not create table (Meals): User: arn:aws:sts::929545228810:assumed-role/homeAssistTemp-role-rz5qgsmq/homeAssistTemp is not authorized to perform: dynamodb:CreateTable on resource: arn:aws:dynamodb:us-east-2:929545228810:table/Meals
Upvotes: 0
Reputation: 903
I found this page in researching and thought I'd post my issue / solution. Wasn't getting exactly exit code 7, but specifically:
Error: Runtime exited with error: signal: killed Runtime.ExitError
No other errors, logs, etc. Previous line gave away the solution:
Memory Size: 1024 MB Max Memory Used: 1024 MB
Was running out of memory on my Lambda function execution. Upped the max memory, and the issue was resolved. Memory is a good thing to check if you see Runtime.ExitError.
Upvotes: 26
Reputation: 181
"Assuming this is a NodeJS lambda, exit code 7 is Internal Exception Handler Run-Time Failure. In other words, you have an uncaught exception. Check your cloudwatch logs for more details." – Anon Coward
wrapping the code in the exports.handler with a try-catch solved my issue
Upvotes: 1