- Published on
How to Deploy a Python App to AWS in Under 15 Minutes
Deploying a Python application to AWS (Amazon Web Services) can be done in under 15 minutes using AWS App Runner. This service automatically handles server provisioning, load balancing, and scaling, allowing you to go from local code to a live URL by simply connecting your GitHub repository.
Why should you choose AWS App Runner for your first deployment?
AWS App Runner is a fully managed service (a platform where the provider handles all the technical background tasks like updates and security). It is designed specifically for web applications and APIs (Application Programming Interfaces). You don't have to worry about managing individual servers or complex networking rules.
For beginners, this is the most direct path because it removes the need to learn EC2 (Elastic Compute Cloud - virtual servers in the cloud) or VPC (Virtual Private Cloud - a private network for your resources). You focus entirely on your code, and AWS handles the infrastructure. It also scales down when no one is using your app, which helps keep costs low.
What do you need before you start?
Before you begin the deployment process, you need a few tools ready on your computer. Make sure you have a basic Python web application, such as one built with Flask or FastAPI.
- An AWS Account: You will need an active account with a payment method on file.
- A GitHub Account: Your code needs to be stored in a GitHub repository (a digital folder for your code).
- Python 3.14+: Ensure your local environment matches the latest stable release.
- A Dockerfile: This is a text file with instructions on how to package your app.
How do you prepare your Python code for the cloud?
To run your app on AWS, you must tell the cloud environment exactly how to set it up. We do this using a requirements.txt file and a Dockerfile. The requirements.txt file lists every library your app needs to function.
In your project folder, create a file named Dockerfile (with no file extension). Paste the following code into it to define your environment:
# Use the latest stable Python version for 2026
FROM python:3.15-slim
# Set the working directory inside the container
WORKDIR /app
# Copy your requirements file first to save time during builds
COPY requirements.txt .
# Install the necessary libraries
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of your application code
COPY . .
# Tell AWS which port your app listens on (usually 8080 for App Runner)
EXPOSE 8080
# The command to start your web server
CMD ["python", "app.py"]
This file acts as a recipe. It tells AWS to start with Python 3.15, move your files inside, install your tools, and start the app. Don't worry if this feels new; Docker is just a way to make sure your app runs the same on your computer as it does on AWS.
How do you connect GitHub to AWS App Runner?
Log into your AWS Management Console and search for "App Runner" in the top search bar. Click "Create an App Runner service" to begin the setup wizard. You will see an option to choose your source code location.
Select "Source code repository" and then click "Add new" to connect your GitHub account. AWS will ask for permission to access your repositories. Once connected, choose the specific repository and the branch (usually named main) that you want to deploy.
In our experience, choosing the "Automatic" deployment trigger is the best way to save time. This setting tells AWS to redeploy your app every single time you push a new update to GitHub. It automates the entire process so you never have to manually upload files again.
What configuration settings should you use?
After selecting your code, AWS will ask how you want to build your application. Choose "Config file" if you have an apprunner.yaml file, but for beginners, selecting "Configure all settings here" is easier. Set the "Runtime" to "Python 3" and the "Build command" to pip install -r requirements.txt.
The "Start command" tells AWS how to launch your app, such as python app.py or gunicorn app:app. You must also specify the "Port," which should match the EXPOSE number you put in your Dockerfile (typically 8080). If these numbers don't match, your app won't be able to talk to the internet.
For the "Compute" settings, you can start with the smallest options: 1 vCPU (Virtual Central Processing Unit) and 2 GB of RAM. This is more than enough for a beginner project or a small personal tool. You can always increase these numbers later if your app gets a lot of traffic.
How do you troubleshoot common deployment errors?
It is normal to see a "Deployment Failed" message on your first try. Most of the time, this happens because of a missing library in your requirements.txt file. If your code uses a tool like pandas or flask but you didn't list it, AWS won't know to install it.
Another common mistake is the "Port Mismatch." If your Python code is set to run on port 5000, but your App Runner settings are looking for port 8080, the connection will time out. Always double-check that your code, Dockerfile, and AWS settings all use the exact same port number.
You can find the "Logs" tab in the App Runner dashboard. This is the best place to look when things go wrong. The "Event log" shows you what AWS is doing, while the "Application logs" show you the actual errors coming from your Python code.
Next Steps
Once your deployment is successful, AWS will provide you with a "Service URL" that ends in .awsapprunner.com. You can share this link with anyone in the world to show off your live application. As a next step, try using Claude Sonnet 4 to help you write a script that connects your app to a database like Amazon RDS.
You might also want to look into setting up a custom domain name so your app looks more professional. AWS App Runner makes this easy by providing a "Custom domains" tab where you can link a URL you own. Keep experimenting, and don't be afraid to break things in your test environment.
For detailed guides, visit the official Python documentation.