https://github.com/rishabkumar7/fastapi-aws-lambda
Deploy FastAPI to AWS Lambda Function
https://github.com/rishabkumar7/fastapi-aws-lambda
Last synced: 12 months ago
JSON representation
Deploy FastAPI to AWS Lambda Function
- Host: GitHub
- URL: https://github.com/rishabkumar7/fastapi-aws-lambda
- Owner: rishabkumar7
- Created: 2024-10-15T20:20:25.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-17T14:23:37.000Z (over 1 year ago)
- Last Synced: 2025-03-01T01:46:32.350Z (12 months ago)
- Language: Python
- Homepage:
- Size: 6.99 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FastAPI App on AWS Lambda
This repository is a demo for hosting a FastAPI application on AWS Lambda using Mangum.
## Project Structure
``` sh
. ├── .gitignore
├── main.py
├── README.md
└── requirements.txt
```
## Requirements
- Python 3.9+
- AWS Account
## Installation
1. Clone the repository:
```sh
git clone https://github.com/rishabkumar7/fastapi-aws-lambda.git
cd fastapi-aws-lambda
```
2. Create a virtual environment and activate it:
```sh
python -m venv .venv
.venv\Scripts\Activate # On Linux/Mac use `source .venv/bin/activate`
```
3. Install the dependencies:
```sh
pip install -r requirements.txt
```
## Running Locally
You can run the FastAPI application locally using Uvicorn, but will need to install uvicorn:
```sh
pip install uvicorn
uvicorn main:app --reload
```
## Deploying to AWS Lambda
Zip your FastAPI application and upload the zip to an AWS Lambda Function.
Zip on Windows:
``` powershell
Compress-Archive .\.venv\Lib\site-packages\* aws_lambda.zip
Compress-Archive .\main.py -Update aws_lambda.zip
```
## Demo
[](https://youtu.be/b0XCH04K8eQ)