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