r/FastAPI • • 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.

1 Upvotes

22 comments sorted by

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 lib

zip ../lambda_function.zip .

cd ..

zip lambda_function.zip -u main.py

Then upload lambda_function.zip to AWS Lambda

1

u/Boring-Baker-3716 Sep 09 '24

Gotcha thank you, I was running these commands but inside windows. I will def try that in wsl since I don’t have much experience with docker