A less likely misunderstanding about how to specify a handler for a zip uploaded with Lambda

Conclusion

Since the Lambda handler specification method is in the format file-name.function-name,

Work record

What I wanted to do

For small services, I wanted to specify a zip version of a set of Lambda functions when creating the function.

Folder structure

+ attakei/
  + __init__.py
  + models.py
  + handlers.py 

Contents of the file (part)

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.

I can't do it for some reason

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

Try & error

A list of things I tried to reach the above conclusion

Around here, I felt like "What is this?" Document Go and solve the problem. You have to read the document properly

complaints

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

A less likely misunderstanding about how to specify a handler for a zip uploaded with Lambda
A story about how to specify a relative path in python.
A story about how to deal with the CORS problem
[Python 3.8 ~] How to define a recursive function smartly with a lambda expression
How to create a serverless machine learning API with AWS Lambda
Think about how to write a filter with the Shotgun API-Contact Versions
How to add a package with PyCharm
[Introduction to Python] How to get the index of data with a for statement
How to read a CSV file with Python 2/3
How to disguise a ZIP file as a PNG file
How to share a virtual environment [About requirements.txt]
How to send a message to LINE with curl
How to specify the NIC to scan with amazon-dash
How to draw a 2-axis graph with pyplot
How to develop a cart app with Django
How to make a dictionary with a hierarchical structure.
Play with Lambda layer (python) for about 5 minutes
How to specify attributes with Mock of python
How to write a ShellScript Bash for statement
How to create a shortcut command for LINUX
How to create a multi-platform app with kivy
[TF] How to specify variables to update with Optimizer
A story about how Windows 10 users created an environment to use OpenCV3 with Python 3.5
How to convert / restore a string with [] in python
[Python] How to draw a line graph with Matplotlib
How to create a submenu with the [Blender] plugin
How to get a logged-in user with Django's forms.py
How to convert a class object to a dictionary with SQLAlchemy
[Python] How to specify the download location with youtube-dl
[Go] How to create a custom error for Sentry
I thought about how to learn programming for free.
How to create a local repository for Linux OS
A story about how theano was moved with TSUBAME 2.0
How to build a development environment for TensorFlow (1.0.0) (Mac)
[Python] How to draw a scatter plot with Matplotlib
I want to bind a local variable with lambda
[Django] A story about getting stuck in a swamp trying to validate a zip with form [TDD]