Deploying a Flask App with AWS App Runner

Goal

I wanted to explore AWS App Runner, so I deployed a basic Python Flask application that connects to a database and returns a list of posts.

Deployment steps

  1. Go to AWS App Runner and start creating a new service.
  2. Choose GitHub as the source. You’ll need to authorize access, but AWS guides you through it with a few pop-up prompts.
  3. Select the desired branch and enable automatic deployment triggers.
  4. I initially selected the Python 3.11 runtime, but due to some errors, I switched to Python 3.9.
  5. Fill in the required fields:
    • Build command: pip install -r requirements.txt
    • Start command: flask run --host=0.0.0.0 --port=8080
    • Port: 8080
  6. Choose the simplest and cheapest instance type.
  7. Set environment variables manually, though using secrets is also supported.
  8. Leave the other settings as default.
  9. Click Save and Deploy. After a few minutes, a default domain is provided for accessing the application.
  10. In my case, I linked the service to a custom subdomain registered through Route 53.

Result

The application was up and running in just a few minutes, with automatic deployment and a custom domain. AWS App Runner proved to be a convenient option for deploying small to medium apps, especially for those already using AWS services.

Leave a Reply

Your email address will not be published. Required fields are marked *