Monday, 3 May 2021

How do I centralize reused custom Python functions in AWS SAM?

I've created a AWS Cloudformation Stack with a template.yaml file that implements several lambda functions. There are several Python functions that some/all of the lambda functions use. Is there a place that I can store common functions? If you think the answer involves layers please address how to include and use custom functions (since the main workflow for layers supports the usual pip python site-package - I'm curious about reusing my own functions).

my project directory:

/lambda_functions
/statemachine
samconfig.toml
template.yaml

The Layer zip looks like this

python/lib/python3.8/site-packages

In site-packages is where I have my other modules - like /requests - which are accessible to the lambda functions (ie. import requests). But if I put my own directory in there /custom_functions with an __init__.py file - lambda functions can not find it.



from How do I centralize reused custom Python functions in AWS SAM?

No comments:

Post a Comment