Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/code4mk/aws-lambda-serverless-fastapi
aws lamda fastapi with serverless
https://github.com/code4mk/aws-lambda-serverless-fastapi
fastapi fastapi-lambda fastapi-sqlalchemy lambda sdeops serverless
Last synced: about 2 months ago
JSON representation
aws lamda fastapi with serverless
- Host: GitHub
- URL: https://github.com/code4mk/aws-lambda-serverless-fastapi
- Owner: code4mk
- Created: 2024-05-25T12:57:43.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-05-31T18:58:59.000Z (8 months ago)
- Last Synced: 2024-05-31T20:12:44.444Z (8 months ago)
- Topics: fastapi, fastapi-lambda, fastapi-sqlalchemy, lambda, sdeops, serverless
- Language: Python
- Homepage:
- Size: 151 KB
- Stars: 12
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# aws-lambda-serverless-fastapi
Deploy fastapi on aws lambda with serverless* production ready
* good project structure
* cd/cd with github action# local development (fastapi)
## python virtual env
```bash
# create virtual environment
python3 -m venv .aws_lambda_fastapi_venv# activate virtual environment
source .aws_lambda_fastapi_venv/bin/activate
```## run fast api project
```bash
# install packages
pip3 install -r requirements.txt# run project with uvicorn
uvicorn "fastapi_project.main:app" --reload --port=8000# or, run bash with shell
./run_fastapi_project.sh
```# deploy on production
## github action
* set secrets `SERVERLESS_ACCESS_KEY` , `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`
NB: you can set environment variable `DATABASE_URL` and `LOAD_SQL_PROJECT` on lamda configuration (Environment variables). LOAD_SQL_PROJECT value will be `yes`
## serverless
* set your own data
```bash
# serverless.yml
org: ****
app: demo-app-api-fastapi
service: demo-app-api-fastapi
```## with cli
```bash
serverless deploy --aws-profile your_aws_profile_name
```# project route
```bash
http://localhost:8000/api/v1/users
http://localhost:8000/health
```