AWS Lambda Docker container runtime error: Runtime exited with error: exit status 127

While testing my Lambda using a Docker container, when the Lambda is invoked, I’m getting this runtime error:

Process 17(bootstrap) exited: Runtime exited with error: exit status 127

Process exit status code 127 errors are usually a file not found error. Going back through the Lambda logs, luckily there’s an error telling me I have an error in my shell script:

/var/task/test.sh: line 5: output: command not found

Quick and easy fix.

AWS Lambda Custom Runtime for executing arm64 binaries

I’m configuring an AWS Lambda with a custom runtime using the Serverless framework, and I’ve run into this error:

Architecture config by default on Lambda is showing x86_64::

If I trying to create with arm64 instead it gives:

An error occurred: HelloLambdaFunction - Resource handler returned message: "Runtime provided does not support the following architectures [arm64]. Please select different architectures from [x86_64] or select a different runtime

This is slightly obscure and it a result of the ‘provided’ runtime coming in 2 flavors, Amazon Linux 1 (provided) and Amazon Linux 2 (provided.al2), and only provided.al2 supports arm64.

If you change your serverless.yaml to include the provided.al2 runtime, then it deploys as expected.

This just means replacing this:

provider:
  name: aws
  runtime: provided

with:

provider:
  name: aws
  runtime: provided.al2

Note now how the runtime shows Amazon Linux 2 and arm64: