3

I am trying to fix an error in my fargate service, where the elastic load balancer health checks keep failing. I know that the issue is not my infrastructure -- because the same cloudformation template works when I use a web application that listens for health checks.

But my current application is a python program adapted from a lambda function. It still needs to run on the lambda stack. So it does not have any health check function and is not returning a success response.

Here are some elements of my dockerfile

# Copy handler function
COPY app/* ${FUNCTION_DIR}
COPY entry.sh /
ENTRYPOINT [ "/entry.sh" ]

EXPOSE 8080
CMD [ "app.handler" ]

And here is the entry.sh file:

#!/bin/sh
if [ -z "${AWS_LAMBDA_RUNTIME_API}" ]; then
    exec /usr/bin/aws-lambda-rie /usr/local/bin/python -m awslambdaric $1
else
    exec /usr/local/bin/python -m awslambdaric $1
fi

This wrapper requires POST requests to be like

curl -XPOST "http:dns-name/2015-03-31/functions/function/invocations" -d '{"args"}'

The app.py file looks like below:

def handler(event, context):
    error_string=''
    class_instance = myClass()
    try:
        data = class_instance.method(args)
    except Error as error:
        errorstring=str(error)
    return errorstring

Can anyone advise on how to add a health check for this app? Would I put it in the docker container or in the app itself?

The health-check path in the ELB is /health-check

mjamo
  • 31
  • 3

0 Answers0