[Serverless Python Tip with SAM]
If you're trying to share code as well as common libraries across a few functions within your project - Check this out
You can use a local path to include requirements.txt, and additional local packages you want 👇
github.com/aws-samples/aw…
However, by only using Lambda Layers it'll break your autocompletion when developing locally incl. tests
For VS Code, you can extend PYTHONPATH by simply adding a `.env` file at the root of your project
👇 /2
github.com/aws-samples/aw…
As for your tests, you'll also have to include that path within your test runner (pytest:conftest.py) or add it programmatically via sys path like this
github.com/aws-samples/aw…
You must be asking: What if I change my shared code frequently?
Then don't use Lambda Layers. Turn that into a private package, specially if other teams are going to use it.
On the good reasons, this reduced ~4m of deployment time + quicker iteration
github.com/aws-samples/aw…
It's important to recognize when tools and frameworks make our life easier.
Big shout out to the SAM team @alexwwood, @jacobf4, @trishika_p, @srirammv_
Personal wishlist now if I may is to make SAM build to work with shared code outside CodeUri too (custom build)
#serverless
Share this Scrolly Tale with your friends.
A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.
