Greengrass error-'module' object has no attribute 'lambda_handler'

0

Hi There,

I am trying to get the example code (to extract MQTT topic and message) run on my Raspberry pi.

CODE-
import greengrasssdk
import logging

client = greengrasssdk.client('iot-data')

OUTPUT_TOPIC = 'test/topic_results'

def get_input_topic(context):
try:
topic = context.client_context.custom['subject']
except Exception as e:
logging.error('Topic could not be parsed. ' + repr(e))
return topic

def get_input_message(event):
try:
message = event['test-key']
except Exception as e:
logging.error('Message could not be parsed. ' + repr(e))
return message

def function_handler(event, context):
try:
input_topic = get_input_topic(context)
input_message = get_input_message(event)
response = 'Invoked on topic "%s" with message "%s"' % (input_topic, input_message)
logging.info(response)
except Exception as e:
logging.error(e)

client.publish(topic=OUTPUT_TOPIC, payload=response)  

return  

I am running this code as a on demand function and greengrasssdk included in the uploaded package.

When I run this I get the following error-

[FATAL]-lambda_runtime.py:356,Failed to initialize Lambda runtime due to exception: 'module' object has no attribute 'lambda_handler'

Please suggest what I may be doing wrong.

Thank you in advance.

Ashish Shukla

gefragt vor 5 Jahren373 Aufrufe
1 Antwort
0

Hi AshishShukia,

Are you able to edit your Lambda function inline, see step 8?
https://docs.aws.amazon.com/greengrass/latest/developerguide/create-lambda.html

Thanks,
KR-AWS

AWS
KR-AWS
beantwortet vor 5 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen