Published on

How to Deploy a Python App on AWS in Under 15 Minutes

Deploying a Python application on AWS (Amazon Web Services) can be completed in under 15 minutes using AWS App Runner, a service that handles server management and scaling automatically. By connecting your GitHub repository to App Runner, you can launch a live URL for your Flask or Django application without manually configuring virtual private servers. This approach eliminates the need to manage infrastructure, allowing you to focus entirely on your code.

Why is AWS App Runner the best choice for beginners?

AWS App Runner is a fully managed service, which means Amazon takes care of the underlying servers, security patches, and scaling. For beginners, this is a huge relief because you don't have to learn complex tools like Kubernetes or manually set up an EC2 (Elastic Compute Cloud - a virtual server in the cloud).

It connects directly to your code repository and automatically redeploys your app whenever you push a change. This creates a "hands-off" workflow where your live website stays updated without extra effort.

We've found that starting with App Runner prevents the common "configuration fatigue" that often stops new developers from finishing their first deployment. It provides a clear path from a local script to a public URL with minimal friction.

What do you need to get started?

Before you begin, ensure you have a few basic tools ready on your computer. Having these set up beforehand will make the process much smoother.

  • An AWS Account: You will need an active account at aws.amazon.com.
  • GitHub Account: Your code needs to be stored in a GitHub repository (a digital folder for your code that tracks changes).
  • Python Installed: Ensure you have Python 3.14 or 3.15 installed on your local machine.
  • A Simple App: A basic Python file using a framework like Flask (a lightweight tool for building web applications).

Step 1: Prepare your Python application

Your application needs two specific files to work on AWS: your main code file and a requirements.txt file. The requirements.txt file tells AWS which libraries (extra tools) your code needs to run.

Create a folder on your computer and add a file named app.py with this code:

# Import the Flask library to create a web server
from flask import Flask

app = Flask(__name__)

# Define what happens when someone visits the home page
@app.route("/")
def hello_world():
    return "Hello, AWS! My Python app is running."

# Start the server on port 8080
if __name__ == "__main__":
    app.run(host="0.0.0.0", port=8080)

Next, create a file named requirements.txt in the same folder. Simply type the word flask inside it and save.

What you should see: You should now have a folder containing exactly two files. These files represent a complete, functional web application ready for the cloud.

Step 2: Push your code to GitHub

AWS needs to pull your code from a central location to deploy it. GitHub is the standard choice for this "Source Control" (a system that saves versions of your work).

Log into GitHub and create a new "Public" repository named my-python-aws-app. Follow the instructions on GitHub to upload your app.py and requirements.txt files to this repository.

Don't worry if you haven't used Git commands before. You can simply use the "Upload files" button on the GitHub website to drag and drop your files into the repository.

What you should see: Your GitHub repository page should now display your two files. This acts as the "source of truth" for AWS to build your application.

Step 3: Configure AWS App Runner

Now, log into your AWS Management Console and search for "App Runner" in the top search bar. Click the "Create an App Runner service" button to begin the setup process.

Select "Source code repository" as your repository type and click "Add new" to connect your GitHub account. AWS will ask for permission to access your repositories; once granted, select your my-python-aws-app repository from the list.

In the "Deployment settings" section, choose "Automatic." This ensures that every time you update your code on GitHub, AWS will automatically update your live website.

What you should see: A green checkmark or a "Connected" status next to your GitHub repository name. This confirms AWS can talk to your code.

Step 4: Set the build and runtime commands

AWS needs to know how to "build" your app (install libraries) and how to "run" it (start the server). In the configuration screen, select "Python 3" as your runtime.

For the "Build command," type: pip install -r requirements.txt. This tells AWS to look at your text file and install Flask.

For the "Start command," type: python app.py. This is the exact command you would use to run the app on your own computer.

Finally, give your service a name, like python-web-app, and keep the default settings for CPU and Memory. These defaults are usually sufficient for a simple beginner project.

What you should see: A summary screen showing your build and start commands. Review these carefully to ensure there are no typos, as even one wrong letter can cause the deployment to fail.

Step 5: Deploy and test your application

Click the "Create & Deploy" button at the bottom of the page. AWS will now begin the process of provisioning (setting up) the hardware and software needed to host your app.

This process usually takes about 3 to 5 minutes. You can watch the "Logs" section to see exactly what AWS is doing, such as installing Flask and starting your script.

Once the status changes from "Operation in progress" to "Running," you will see a "Default domain" URL. It will look something like https://random-string.us-east-1.awsapprunner.com.

What you should see: Click that URL, and a new browser tab should open. You should see the message: "Hello, AWS! My Python app is running."

Troubleshooting common deployment errors

If your deployment fails, don't panic; this is a normal part of the learning process. Most errors happen because of small configuration mistakes.

  • Port Issues: Ensure your app.py is set to port 8080. AWS App Runner expects traffic on this port by default, and using a different one might cause a "Health Check" failure.
  • Missing Dependencies: If you get an "ImportError," check your requirements.txt file. Make sure every library you used in your code is listed there.
  • Runtime Version: Ensure you selected the correct Python version in the AWS console. If you wrote code for Python 3.15 but selected Python 3.10, some features might not work.

We have found that checking the "Service logs" in the App Runner dashboard is the fastest way to identify these issues. The logs will tell you exactly which line of code caused the error.

Next Steps

Now that your app is live, you can try making a change to app.py on your computer and pushing it to GitHub. You will see AWS automatically start a new deployment to reflect your changes.

To take your skills further, you might explore connecting a database like Amazon RDS (Relational Database Service) to store user information. You can also experiment with using more advanced AI models like Claude Sonnet 4 to help you write more complex Python logic for your site.

For more detailed guides, visit the official Python documentation.


Read the Deploy Documentation