Skip to content

Instantly share code, notes, and snippets.

@oscarnevarezleal
Created May 8, 2024 23:17
Show Gist options
  • Save oscarnevarezleal/0cbd7ff8a2e58d28c610719b7da334f8 to your computer and use it in GitHub Desktop.
Save oscarnevarezleal/0cbd7ff8a2e58d28c610719b7da334f8 to your computer and use it in GitHub Desktop.
Custom CMD handler based on environment variables
FROM public.ecr.aws/lambda/python:3.9
ARG HANDLER_PATH="src.entrypoints.listener.handler.handler"
ENV HANDLER_PATH="${HANDLER_PATH}"
#....
ENTRYPOINT [ "./lambda-entrypoint.sh" ]
#!/usr/bin/env bash
# shellcheck disable=SC2034
export _HANDLER="${HANDLER_PATH}"
RUNTIME_ENTRYPOINT=/var/runtime/bootstrap
if [ -z "${AWS_LAMBDA_RUNTIME_API}" ]; then
exec /usr/local/bin/aws-lambda-rie $RUNTIME_ENTRYPOINT
else
exec $RUNTIME_ENTRYPOINT
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment