We can use a lambda function to connect to AWS IoT Greengrass core and publish messages. For device to receieve msg published by lambda, 2 things need to be satisfied: 1) There needs to be a subscription to the lambda in the greengrass (with appropriate topic) and 2) the subscriber's code does a .subscribe
to that topic. Lambda example:
import greengrasssdk
import json
# Greengrass client to publish to
client = greengrasssdk.client('iot-data')
# Executed on every messages received from the subscription
def lambda_handler(event, context):
client.publish(topic='lab/greengrass/telemetry', payload=json.dumps(event))
return
Here the message is published in context of the Lambda and not a device. Similarly if I had to send msg from lambda to AWS IoT Core, the msg doesn't go from context of lambda as a device, but lambda itself.
However, we could also publish message via Lambda that represents a thing to AWS IoT Core or other device, and for this we will need to pass in credentials (thing credentials) to identify the Lambda as a device (thing).
Have I understood this right?