Reputation: 39
I have my app.py function that's using pip libraries like SQLAlchemy, etc... I am deploying this to AWS Lambda, so I am packaging app.py and all other dependencies into a zip.
Upvotes: 3
Views: 3501
Reputation: 427
Yeap, I'll give you some alternatives to each of your questions:
Kind of, you could use a *framework (chalice/serverless) to automatically handle packaging for you. Each deploy would fetch the most recent version (according to your requirements.txt
) and package then for you. I recommend you to stick with a framework.
A Lambda Layer is exactly what you need - Multiple lambdas will be able to run your module without overhead (in simple terms). There are a lot o references explaining how to create a layer and also about python packaging (You're the one who must evaluate the need to upload it to pypi)
In both cases, serverless
is going to help you a lot !
Upvotes: 3
Reputation: 12895
Regarding 1 - AWS SAM will work out your requirements.txt
and bundle what's needed with your code. This works fine for small projects, but for larger ones I'd suggest going the same way as for library code - put all your deps in separate layer. It may be installed with pip install -U --target dirname
and then packaged into a layer.
Upvotes: 0