AWS Lambda Handler

0

So I am receiving this error whenver I try to run my lambda function: { "errorMessage": "Handler 'lambda_handler' missing on module 'lambda_function'", "errorType": "Runtime.HandlerNotFound", "requestId": "", "stackTrace": [] } My lambda handler is correctly named as lambda_handler(event, context). My thought: My lambda function is trying to connect to a MS SQL Server and it does this by importing pymssql so the structure of my lambda function along with the dependencies might be causing the issue. Please let me know if you kno w a fix or can explain what the structure should looks like

Omar
asked 10 months ago1512 views
1 Answer
4
Accepted Answer

This error is most likely coming due to lambda function is missing pymssql. Here is how you would add pymssql module to your lambda by creating a layer first:

1: Download the library onto your local environmen

   pip install -t ./python pymssql

This would place the pymysql library into a folder named "python" on your present working directory.

Or

    mkdir python
    cd python
    python3 -m pip install --upgrade pip
    python3 -m pip install PyMSSQL 

2: Zip the "python" folder

 zip -r pymysql.zip python

3. Go to Lambda console -> in the left pane -> Additional Resources -> Layers

  1. Create Layer

  2. Give it a name -> Upload zip file -> Give the runtime detail, should match your lambda function run time

  3. Now go to Lambda function -> Scroll down to the bottom

  4. Layers -> Add Layer -> Now add the layer which you created in previous steps.

This would resolve this issue.

Hope you find this useful. Comment here if you have additional questions.

Abhishek

profile pictureAWS
EXPERT
answered 10 months ago
profile pictureAWS
EXPERT
iBehr
reviewed 9 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions