Reputation: 4052
I built a simple lambda function using AWS Cloud9. Now I want my lambda to do a bit more. So I created another python file with some functions and saved it in the same directory.
myLambdaName
- myLambdaName
- lambda_function.py
- other_function.py
In my lambda function, I try to import this ( import other_function
).
If I run the function in the cloud9 terminal, no issues (python3 lambda_function.py
). But when I go to test the lambda function locally, via AWS Resources tab > Run (local), I get the error that my new python file doesn't exist:
Unable to import module 'myLambdaName/lambda_function': No module named 'other_function'
What am I missing here? How do I tell the lambda to pick up the file?
Upvotes: 1
Views: 974
Reputation: 3984
Add your function name to the import path, like
import myLambdaName.other_function
See screenshot below for example that I've just tested with ApplicationName
being the application name, while FunctionName
being the function name.
Upvotes: 2