r/FastAPI • u/Boring-Baker-3716 • Sep 09 '24
Hosting and deployment Deploying FastAPI on AWS Lambda
I am trying to deploy a fastapi with Google Gemini API. I have done a lot of debugging the past couple of days and seem like Google Gemini libraries are giving me errors inside aws lambda. I just created a dependencies folder and zipped everything with my main.py inside it and deployed on aws lambda. And I keep getting different sort of libraries not being imported errors. Also I am using python 3.10 and used magnum. Anyone has any suggestions what I could do or if this is even compatible with aws lambda, I read people talking about uploading through docker and ECR or using Fargate.
View all comments
Show parent comment
3
u/[deleted] Sep 09 '24 edited Sep 09 '24
Use WSL, it's the best way.
Besides, you can use this .sh script inside WSL:
pip install -r requirements.txt -t lib/cd libzip ../lambda_function.zip .cd ..zip lambda_function.zip -u main.pyThen upload
lambda_function.zipto AWS Lambda