I'm fairly new to working with AWS and have been diving into using Lambda functions for serverless features instead of containers. While it's been going well overall, I've hit a roadblock with the limit on custom lambda layers. I know I can store third-party libraries on an EFS network drive and have my Lambda pull them from there, but that feels overly complicated and not very best-practice-like. I'm looking for better ways to install third-party libraries, especially with Python, as the AI tools are getting more numerous and it's difficult to manage a growing list of libraries served from a network drive. Is there a simpler way to add these libraries to my AWS Lambda stack while staying serverless?
5 Answers
If you're mindful of the package size, messing with layers might not even be necessary. Look into how you’re deploying your Lambda functions. The Serverless Framework with the serverless-python-requirements plugin could make things a lot easier for you — it’s more hands-off!
Honestly, Lambda Containers could be a better option for your situation. Containers can hold more dependencies without the hassle of layers and could simplify your deployment process. Give it a shot if you haven’t already!
Using Lambda layers is standard practice. If you store your library contents on GitHub, you can have a build script that zips them up to use as layer resources for your Lambda. Just think about managing complexity. If your packages are too bulky, it might be a signal to consider other solutions like EC2 or containers instead.
You might want to consider packaging your dependencies in Docker images. It allows you to bundle everything you need without running into layer limits. Plus, if you’re familiar with Docker, it can streamline your workflow a lot!
Another approach is to create custom Lambda runtimes. Using the Amazon Linux runtime has worked well for me, especially when utilizing the AWS CLI instead of interacting with the boto3 API directly. This might give you more flexibility!

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically