Since the Lambda handler specification method is in the format file-name.function-name
,
For small services, I wanted to specify a zip version of a set of Lambda functions when creating the function.
+ attakei/
+ __init__.py
+ models.py
+ handlers.py
attakei/handlers.py
def get_articles(event, context):
return {}
def search_by_tags(event, context):
return {"""something"""}
I want to manage the function as a set by specifying various handlers like attakei.handlers.get_articles when creating the Lambda function with the configuration like.
In this state, create a zip according to the AWS rules and upload it to S3 → If you specify a handler in the above format, it will not work at all when executing Test. Such a log keeps appearing.
Unable to import module 'attakei.handlers': No module named attakei.handlers
A list of things I tried to reach the above conclusion
from attakei.handler import get_articles
in main, and register main.get_articles as a handler ... OKAround here, I felt like "What is this?" Document Go and solve the problem. You have to read the document properly
When defining a console command when creating a python package, it is described as module path: function name
, so it seems that my brain was stagnant because I completely turned my consciousness to that.
However, I personally appreciate it if you matched this format ...
Recommended Posts