0

In order to send data from Greengrass lambda to AWS IoT Core rules engine,we need to create a subscription with source as the Lambda and target as IoT Core.

Should lambda identify itself as an IoT device (thing, with credentials) to the IoT core via device sdk? Or is this optional and the lambda can alternatively send data to IoT Core directly using greengrass sdk?

variable
  • 8,262
  • 9
  • 95
  • 215

1 Answers1

1

Nope. The lambda doesn't have to be configured as a thing as long as it is part of the Greengrass group and is executed in the Greengrass core.

Checkout the AWS official docs on Subscriptions and it will help you understand further

Greengrass allows Subscriptions to and from 4 different options

enter image description here

Devices/Lambdas/Connectors/Services to other Devices/Lambdas/Connectors/Services

Publishing data to AWS IoT Core comes into the Services option as IoT Cloud

Dr Things
  • 51
  • 4
  • Yep, totally! If we configure the Lambda within a GG group as a thing, the code in lambda can subscribe to topics without having to configure the subscription in GG group – Dr Things Oct 22 '20 at 04:49
  • Assuming we have a greengrass setup, are you saying that greengrass subscription is required only for communication between device and lambda and vice-versa? And greengrass subscription is not require for communication between the devices? – variable Oct 22 '20 at 04:52
  • Nah, we can use greengrass subscription to exchange messages among devices or among lambdas as well... I've updated the response, it might help! – Dr Things Oct 22 '20 at 05:01
  • In your comment above you have said `If we configure the Lambda within a GG group as a thing, the code in lambda can subscribe to topics without having to configure the subscription in GG group` - I am confused on this because you rightly said that code in lambda (thing) can subscribe to topics - but without having subscription in GG group, how will the msg reach the lambda (thing)? – variable Oct 22 '20 at 05:09
  • Well, if the lambda is configured not to time out (or until it times out) and once triggered/invoked, it will keep listening for a topic from IoT Core just the way a python code in your PC could listen to that topic. Although we lose the purpose of having it in a GG group, it is still possible. – Dr Things Oct 22 '20 at 05:15
  • In your above example, assuming the lambda is a thing (device) belonging to greengrass group (not IoT core), then to be able to receive msgs, will it need subscription to other things in the greengrass group, in addition to the python code `.subscribe(topic..)`? My point of confusion is that - subscription traditionally meant subcribing to a topic but in context of greengrass I think subscription means subscribing to device (or lamda, service, connector) and topic. – variable Oct 22 '20 at 05:25
  • Subscription in Greengrass also happens to topic only... Instead of the conventional way where the AWS IoT Core remains an MQTT broker, the Greengrass Core becomes the broker...so any device / lambda / connector / services that publish an MQTT message goes to the broker first (In GG group, its the core)... no matter if other entities in the GG group have subscribed to that topic or not, unless we configure subscriptions in the GG group that allows routing of messages from one entity to the other for a specified topic, the messages don't get transferred. And yes you are right! – Dr Things Oct 22 '20 at 05:45