1

I made 2 Lambda functions (LambdaFunction_1 and LambdaFunction_2). I have deployed LambdaFunction_1 on my AWS-Greengrass core which is RaspberryPi 3 to be the local lambda function. I want to invoke LambdaFunction_1 from LambdaFunction_2. The local lambda function can't be invoked for strange reason that I can't understand.

To deploy the local lambda function (LambdaFunction_1) I have to upload a zip file containing the python file of the code and the greengrasssdk. Importing this greengrasssdk in the code makes it unable to be invoked!

This is the code for LAmbdaFunction_2 which is on cloud:

import json
import boto3
invokeLam = boto3.client('lambda')
def lambda_handler(event, context):   
payload = {'test-key': 'Hi, you have been invoked!'}
response_F1 = invokeLam.invoke(
                               FunctionName = 'LambdaFunction_1', 
                               InvocationType = 'RequestResponse', 
                               LogType='None', 
                               Payload = json.dumps(payload) 
                              )
data_F1 = response_F1['Payload'].read()
print (data_F1)
return

This is the code of LambdaFunction_1 which is deployed on greengrass core:

import json
import greengrasssdk
def function_handler(event, context):
    print (event)
    return 'Hello From Function 1'

The output should be "Hello From Function 1" in the log file of Function 2. But the response is {"errorMessage": "Unable to import module 'LambdaFunction_1'"}

BUT: when I remove (import greengrasssdk) line from the code of function one it works perfectly. Is this problem logical?

  • 1
    Did you check the logs of the LambdaFunction_1? It should have some kind of error related to greengrass. Also, what runtime are you using? – Stargazer Mar 29 '19 at 11:15
  • 1
    I am using Python 2.7 Runtime. I got this error from the log file of LambdaFunction_1: Unable to import module 'LambdaFunction_1': No module named greengrass_common.function_arn_fields – Abdelhamied Raslan Apr 01 '19 at 08:53

1 Answers1

1

I found the solution that I have to import two libraries in LambdaFunction_1 beside greengrasssdk which are: 1- greengrass_ipc_python_sdk 2- greengrass_common

I got the answer by viewing the log files of LambdaFunction_1 as advised by @Stargazer