Updating greengrass device shadow from Lambda using greengrass sdk

0

Hi, I am very much intreseted in greengrass, I came across below defined problem.

I am trying to update a greengrass group device from a lambda function online. I have attached the greengrasssdk along with my python program and uploaded it as .zip for setting up the lambda function. The python program is as below which i found on another thread here.

import greengrasssdk
import json 
iot_client = greengrasssdk.client('iot-data')
 
def handler(event, context):
      print event
      thing_name = 'Raspberry_lights',
      
      update_state = {
	"state": {
		"desired":{
			"property":event["message"]
		      }
	      }
      }
      
     
      iot_client.update_thing_shadow(
          thingName=thing_name,
          payload=json.dumps(update_state),
      )

But I get an import error as below,

Unable to import module 'updateshadows': No module named greengrass_common.function_arn_fields

updateshadows is the name of my lambda function. Also please let me know what all policies has to be attached to the role for this lambda function.

My device is 'synced to cloud'. Do i need to upload another packages along with greengrasssdk ? or should i add any additional subscriptions, i read that if you are trying to change the local device shadow from an lambda function online, you dont require any authentication and dont need to setup any subscriptions in greengrass group. Is it correct ? how should i solve this error ?

Edited by: jovel on Mar 26, 2019 8:18 AM

jovel
asked 5 years ago263 views
1 Answer
0

Hi Jovel,

Are you following the steps outlined here?
https://docs.aws.amazon.com/greengrass/latest/developerguide/create-lambda.html

If you go to the console -> Lambda, are you able to "Edit code inline" for your Lambda function? Where are you seeing that error?

Thanks,
KR-AWS

AWS
KR-AWS
answered 5 years 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