- Newest
- Most votes
- Most comments
By default, the Lambda engine calls your function and is looking for an entry point like:
def lambda_handler(event, context):
# your code goes here
You can see this when you create a new Python function.
If you're concerned about keeping your function warm, Lambda provisioned concurrency is normally a better way to go.
I recently faced a similar issue and the solution is provided at https://repost.aws/questions/QU0A9xe6i_T6CfOWLeiWm4XA/api-gateway-with-lambda-unable-to-import-module-server-no-module-named-server
An example of handler is located at https://github.com/fortejas/example-serverless-python-api/blob/main/lambda-api/server.py
handler = Mangum(app)
You would also need to install the required python dependencies
Sample commands
curl -O https://bootstrap.pypa.io/get-pip.py
sudo python3.7 get-pip.py
python -m pip --version
rm get-pip.py
pipenv
cd lambda-api/
virtualenv -p /usr/bin/python3.7 vpy37
source vpy37/bin/activate
pip3 install fastapi
pip3 install boto3
pip3 install Magnum
pip3 install uvicorn
I have installed all dependencies but error continues
Would you be able to post your code to a git repo/pastebin and provide the steps on how to reproduce the issue?
Relevant content
- asked a year ago
- Accepted Answerasked 10 months ago
- AWS OFFICIALUpdated 10 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 3 years ago
I used this approach but got this error Execution failed due to configuration error: Malformed Lambda proxy response. My app works fine with mangum but problem on schedule event.