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?

2
  • 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? Commented Mar 29, 2019 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 Commented Apr 1, 2019 at 8:53

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.