I have a Dockerfile and I am taking in a LAMBDA_NAME from a jenkins pipeline.
I am passing in something like this: source-producer
And I want to call the handler of this function, which is named handler in the code.
This code does not work
ARG LAMBDA_NAME
ENV LAMBDA_HANDLER="${LAMBDA_NAME}.handler"
RUN echo "${LAMBDA_HANDLER}"
CMD [ "${LAMBDA_HANDLER}" ]
The result of the run echo step gives back "sourceproducer.handler", which is correct.
The code above produces this error [ERROR] Runtime.MalformedHandlerName: Bad handler '${LAMBDA_HANDLER}': not enough values to unpack (expected 2, got 1)
But, when this same value is hardcoded, it works fine and executes the lambda function.
ARG LAMBDA_NAME
ENV LAMBDA_HANDLER="${LAMBDA_NAME}.handler"
RUN echo "${LAMBDA_HANDLER}"
CMD [ "sourceproducer.handler" ]
How can I correctly use LAMBDA_HANDLER inside of CMD so that the top code block executes the same as the one below it?