pythonamazon-web-servicesaws-app-runnerdocker-healthcheck

Unable to run a simple python application in AWS App Runner


Has any deployed a python application on AWS app runner recently ? I have tried a lot of different ways and they all fail with the same error

01-01-2025 04:44:22 PM [AppRunner] Health check failed on protocol `HTTP`[Path: '/'], [Port: '8080']. Check your configured port number. For more information, see the application logs.
01-01-2025 04:44:35 PM [AppRunner] Deployment with ID : 9719e0a9f3814a5d88c90569994bb10c failed. Failure reason : Health check failed.

I started with my python application and moved to simple python hello world samples like these https://github.com/Sathyvs/apprunner https://github.com/adamjkeller/simple-apprunner-demo (this is a code the author put on a youtube video that shows everything just working fine, but when I fork this repository and run it, I get the same above issue.

I have tried

But every attempt have failed at the exact same step. and if you see this file here https://github.com/Sathyvs/apprunner/blob/main/server.py I added some logs and while I see the logs on start up in local machine, I do not see any application logs on app runner, it only gives the same limited logs and there is no additional information on what is going on with the deployment ?

Code at https://github.com/Sathyvs/apprunner/tree/main server.py

from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
import os, logging

logging.basicConfig(level=logging.INFO, stream=sys.stdout)
logger = logging.getLogger(__name__)

def hello_world(request):
    name = os.environ.get('NAME')
    if name == None or len(name) == 0:
        name = "world"
    message = "Hello, " + name + "!\n"
    logger.info("api called")
    return Response(message)

if __name__ == '__main__':
    port = int(os.environ.get("PORT"))
    logger.info(f"running main application and listening on port {os.environ.get("PORT")}")
    logger.info(f"value of my port {os.environ.get("MY_PORT")}")
    with Configurator() as config:
        logger.info("configuring apis")
        config.add_route('hello', '/')
        config.add_view(hello_world, route_name='hello')
        app = config.make_wsgi_app()
    server = make_server('0.0.0.0', 8080, app)
    logger.info("starting server")
    server.serve_forever()

Dockerfile

FROM public.ecr.aws/amazonlinux/amazonlinux:latest
RUN yum install python3.7 -y && curl -O https://bootstrap.pypa.io/get-pip.py && python3 get-pip.py && yum update -y
COPY . /app
WORKDIR /app
RUN pip3 install -r requirements.txt
CMD python3 server.py
EXPOSE 8080

Has any one faced these challenges and actually deployed an application in App runner ? Is there any sample out there that actually runs a python application on app runner ? does app runner actually work at all ?

I appreciate any help or clue to even find out some more logs on what is going on. Thank you.


Solution

  • Thank you for the comments and trying to replicate the issue. Since all my attempts failed, I reached out to AWS support and they mentioned, they refreshed my account and after which I am able to deploy the samples or the startup guide examples without any issue. This was their comment

    I would like to inform you that Based on your account usage, the quotas related to Apprunner service were restricted for your AWS Account due to which Apprunner instances were not getting launched in Apprunner service due to which the application wasn't getting started (consequently not generating application logs), as a result, the healthchecks were getting failed. Also, your account activity is constantly monitored within each Region, and these quotas are automatically increased based on your usage.