I've been writing an application on AWS that consists of several Rust lambdas. One of those lambdas has to have access to a bunch of external dependencies and therefore needs to be Dockerized. As I understand, the official AWS Lambda runtime for Rust runs within the lambda's binary and shouldn't need any special setup or exposing of ports. My Dockerfile is as follows:
# building omitted
FROM alpine:latest AS runner
WORKDIR /root/
COPY target/x86_64-unknown-linux-musl/release/my-lambda ./my-lambda
CMD [ "/root/my-lambda" ]
The image then gets built and pushed to an Amazon ECR registry my Lambda is configured to get its code from. The logs I get when invoking the function with any test data in the AWS console are:
IMAGE Launch error: fork/exec /root/my-lambda: permission denied Entrypoint: [] Cmd: [/root/my-lambda] WorkingDir: [/root/]
START RequestId: (...) Version: $LATEST
IMAGE Launch error: fork/exec /root/my-lambda: permission denied Entrypoint: [] Cmd: [/root/my-lambda] WorkingDir: [/root/]
END RequestId: (...)
REPORT RequestId: (...) Duration: 59.75 ms Billed Duration: 60 ms Memory Size: 128 MB Max Memory Used: 5 MB
RequestId: (...) Error: fork/exec /root/my-lambda: permission denied
Runtime.InvalidEntrypoint
{
"errorMessage": "RequestId: (...) Error: fork/exec /root/my-lambda: permission denied",
"errorType": "Runtime.InvalidEntrypoint"
}
I know the problem is not with:
- the
my-lambdaexecutable file's permissions (anyone can execute it, I've tried chmod -R 777 for good measure too) - the availability of libc (I specifically compiled for the musl target, as is best practice for Rust lambdas due to the Rust stdlib almost always linking to a newer glibc than Amazon Linux has)
- whether or not the Docker image even runs - if I try to run the image locally, my lambda runs and crashes on not finding the AWS_LAMBDA_RUNTIME_API env var or other variables lambdas depend on, as expected
- the executable's naming or if it's invoked with a relative path - naming it
bootstrapin line with lambda convention and finishing withCMD ["./bootstrap"]did not help
I've also tried using an ENTRYPOINT rather than a CMD in the dockerfile, as well as providing a placeholder CMD like doesnt.matter.
Googling around for a solution has only turned up Rust lambda builder images and similar-looking but unrelated errors for Golang.