Skip to content

App Runner Getting Started guide doesn't work

0

I can't get App Runner to work, at all.

I've created a GitHub repo with just the two files in the getting started guide (requirements.txt and server.py) and followed all the other steps. I'm logged in as an IAM user in the Administrators group. It fetches the code from the repo, runs pip install successfully, then just fails.

The last few lines of logs in the App Runner console are:

11-28-2024 02:14:31 PM [Build] Successfully built AAAAAAAAAAAAAAAA
11-28-2024 02:14:31 PM [Build] Successfully tagged application-image:latest
11-28-2024 02:14:46 PM [AppRunner] Successfully built your application source code.
11-28-2024 02:21:29 PM [AppRunner] Failed to deploy your application source code.

Not very helpful!

(I'm replacing any IDs with AAA because it won't let me use X's, silly!)

Also I don't know if I'm supposed to see any [Run] entries in there

The tail of the logs in CloudWatch are this:

[Build] Successfully tagged application-image:latest
[AppRunner] Successfully built your application source code.
[AppRunner] Failed to deploy your application source code.

And in CloudWatch under 'events' the last few lines are this:

[AppRunner] Performing health check on protocol `TCP` [Port: '8080'].
[AppRunner] Health check failed on protocol `TCP` [Port: '8080']. Check your configured port number. For more information, see the application logs.
[AppRunner] Deployment with ID : AAAAAAAAAAAAAAAA failed. Failure reason : Health check failed.

Nowhere can I see that it's actually trying to run my 'start command (python server.py- as per the getting started guide) and I can't see any output from theserver.py` file.

Sometimes in the App Runner Console I get this warning at the top of the page, but I think that's maybe just because the build fails?

Web ACLs are not available for the selected service arn:aws:apprunner:us-west-2:AAAAAAAAAAAAAAAA:service/getting-started/AAAAAAAAAAAAAAAA because the service does not exist or is in an invalid state for association

Things I've tried:

  • Python 3.11 runtime instead of Python 3 runtime (needed to change pip install to pip3 install, another pain point!)
  • Hard coding the port in server.py in case the PORT env var wasn't being set
  • Using an HTTP health check instead of TCP
  • I'm not trying to do anything fancy like config files, deploying with the CLI etc, just trying the bare minimum to get something deployed

Is someone at AWS able to actually run through the getting started guide themselves and confirm that it works? The only thing I haven't done is follow all the things on the 'setting up' page, like "Enable IAM Identity Center" because I'm just doing this as a test in a personal account and other pages suggested that this wasn't necessary. The only other maybe odd thing is that my GitHub repo is private, but it successfully accesses it and runs the build, so I don't think that's relevant.

asked 2 years ago693 views

1 Answer
0

I apologize for the difficulties you're experiencing with AWS App Runner. Based on the information you've provided, it seems that the main issue is related to the health check failing, which is preventing your application from deploying successfully. Let's address some potential causes and solutions:

  1. Port Configuration: Ensure that your application is actually listening on port 8080. In your server.py file, make sure you're binding to the correct port. For example:

    app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 8080)))
  2. Start Command: Verify that your start command is correct. In the App Runner configuration, ensure it's set to python server.py.

  3. Environment Variables: Make sure the PORT environment variable is set correctly in your App Runner service configuration.

  4. Dependencies: Double-check your requirements.txt file to ensure all necessary dependencies are listed.

  5. Application Errors: Your application might be crashing on startup. Try adding some print statements or logging in your server.py file to help diagnose any potential issues.

  6. Runtime Version: While you've tried both Python 3 and Python 3.11, ensure you're using a compatible version for all your dependencies.

  7. Permissions: As an IAM user in the Administrators group, you should have sufficient permissions. However, verify that App Runner has the necessary permissions to access your GitHub repository and deploy the application.

  8. Timeout: The health check might be failing if your application takes too long to start. You could try increasing the health check timeout in your App Runner configuration if this is the case.

Regarding the warning about Web ACLs, this is likely due to the failed deployment and shouldn't be the root cause of your issue.

For the lack of [Run] entries in the logs, this is expected if the deployment fails before reaching the run stage.

To troubleshoot further:

  • Add more logging to your application to see if it's starting up correctly.
  • Try deploying a simpler application (e.g., a basic "Hello World" Flask app) to isolate whether the issue is with your specific application or the App Runner configuration.
  • Check if there are any resource constraints (e.g., memory limits) that might be causing the application to fail silently.

If these steps don't resolve the issue, it may be worth reaching out to AWS support for further assistance, as they can look into account-specific details that might be causing the problem.
Sources
Getting started with App Runner - AWS App Runner
App Runner configuration file reference - AWS App Runner
App Runner configuration file examples - AWS App Runner

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.