Blog
Tutorial

Deploy a Flask app to your own cloud without DevOps

How to deploy a Python Flask app to your own AWS account without writing Terraform or learning cloud ops. From git repo to live endpoint — minutes, not days.

Tobi

Flask apps are minimal by design. A routing layer, some endpoints, a requirements.txt. The app is often a few hundred lines. Getting it running in your own cloud account — VPC, IAM roles, container registry, load balancer — can take days of console work or a Terraform module you'll be maintaining forever.

The ops overhead isn't proportional to the app. This post shows how to skip it: your Flask app, in your own cloud account, without a DevOps hire and without writing a line of infrastructure config.


Why deploying to your own cloud is usually heavy

Cloud infrastructure isn't hard in any one place — it's the number of places. A containerised Python app in AWS involves IAM role creation, ECR repository setup, ECS task definition, Application Load Balancer with TLS, VPC configuration, and security group rules. Each piece is documented. Together, they add up to hours of console work and an IaC module you didn't plan to own.

Managed PaaS (Render, Railway, Heroku) exists because that overhead is real. It removes the ceremony but trades away ownership — your app runs on their infrastructure, under their SLA, on their pricing model.

The ceremony is the problem, not the outcome.


Before you start

You'll need a Leanly account with your cloud account and GitHub connected. If you're new to Leanly, sign up here, install the CLI (npm install leanly --global), and connect your accounts — a one-time setup.

For this guide: your Flask app in a GitHub repo.

If you want to follow along with a minimal example, fork leanlydev/leanly-example-flask-app — it's ready to deploy as-is. The app looks like this:

app.py

"""Minimal Flask demo app for leanly.dev."""

import os

from flask import Flask

app = Flask(__name__)


@app.route("/")
def hello_world():
    """Example Hello World route."""
    name = os.environ.get("NAME", "World")
    return f"Hello {name}!"


if __name__ == "__main__":
    app.run(debug=True, host="0.0.0.0", port=int(os.environ.get("PORT", 8080)))

The deployment

Step 1 — Run leanly init

In your repo:

leanly init

This opens the Leanly UI in your browser.

Step 2 — Watch us analyse your repo

We analyse your repository and determine what it needs to deploy in your cloud account — the right services, sensible defaults, no input from you. Flask apps are containerised, so ECS on Fargate is the most common recommendation — but we may suggest something different depending on your workload's scaling, cost profile, or region requirements. You see exactly what's being created before anything executes.

Step 3 — Select your deployment target

If you have multiple cloud accounts connected, we'll show recommendations across all of them. Select the cloud account you want to deploy to. If we've suggested options across clouds, pick the ECS recommendation to stay on AWS — or choose whichever fits your requirements best.

Step 4 — Add environment variables and confirm

We show you what we recommend deploying before anything is created. Review the proposal, add any environment variables your app needs (database URL, API keys, SECRET_KEY), then hit Create application.

Tip: You can drag and drop a .env file directly onto the environment variables section to import them in bulk.

We build and provision everything in your account. You'll have a live HTTPS endpoint shortly.

Step 5 — Verify

Hit the endpoint. Check your critical paths. Then open your AWS console — you'll see the actual resources running in your own account, visible and editable.


What you end up with

After deployment, your Flask app runs in your AWS account. The exact resources depend on what we recommend for your workload — Flask apps are containerised, so ECS on Fargate is the most common outcome, but we may suggest something better suited to your scaling or cost profile. For ECS, you end up with:

  • ECS service — your container, running on Fargate (no cluster to manage)
  • Application Load Balancer — public HTTPS endpoint, TLS handled
  • ECR repository — your container images
  • VPC, security groups, IAM roles — provisioned with sensible defaults; all visible in your AWS console

Whatever we recommend, you own all of it. We provisioned it; you can inspect it, extend it, or hand it to another tool later.

Pushing new versions works the same way as any deployment: push to your main branch, we build and deploy automatically via the GitHub integration.


What you give up

No database provisioning. We deploy your app, not your database. If your Flask app connects to Postgres or another store, bring the connection string as an environment variable. Connect to a managed database in your AWS account or elsewhere — we'll provision the app around it.

No custom IAM policies out of the box. We provision a minimum-privilege IAM role for your deployment. If your app requires specific custom IAM permissions beyond what we provision, you'll configure those in your AWS console after the first deploy.

We use cookies to enhance your experience and analyze site traffic. Read our cookie policy.