aws / aws/aws-lambda-base-images
Unable to over-ride entrypoint, command, working directory at run-time/lambda create_function
- Dominant language
- No language data
- Stars
- 777
- Forks
- 118
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
I have a built a custom docker image on top of `public.ecr.aws/lambda/python:3.9` as follows
> FROM public.ecr.aws/lambda/python:3.9
>
> ENV PATH ${LAMBDA_RUNTIME_DIR}:$PATH
>
> RUN yum install git -y
> RUN pip3 install awscli --target "${LAMBDA_TASK_ROOT}"
> RUN pip3 install boto3 --target "${LAMBDA_TASK_ROOT}"
>
>
> COPY app.py ${LAMBDA_RUNTIME_DIR}
> RUN chmod +x ${LAMBDA_RUNTIME_DIR}/app.py
>
> WORKDIR ${LAMBDA_RUNTIME_DIR}
> CMD [ "app.handler" ]
The app.py has a handler code defined in a standard format -
`def handler(event, context):
try:
sys.argv.pop(0)
for arg in sys.argv:
print(" ", arg)
....
return result`
Now, am creating a lambda function using this docker image where the call signature is
> img_cfg = {
> "EntryPoint": ["app.handler"],
> "Command": [*handler_args],
> "WorkingDirectory": "/var/runtime"
> }
> client.create_function(
> FunctionName=function_name,
> Role=role_arn,
> Code={"ImageUri": f"{repository}@{digest}"},
> PackageType="Image",
> ImageConfig= img_cfg,
> MemorySize=opt_args.get("memory_size", DEFAULT_MEMORY),
> Timeout=opt_args.get("timeout", DEFAULT_TIMEOUT),
> )
I keep getting the below error in the output when the lambda is invoked -
`Error: exec: "app.handler": executable file not found in $PATH Runtime.InvalidEntrypoint`
For `img_cfg` if I pass an empty json, i.e., `{}` the function works.
What am I missing?
Contributor guide
Assessment
This issue has not been assessed yet.