Triggers for Yandex IoT Core
Trigger for Yandex IoT Core is designed for managing messages exchanged by the devices and registries. The trigger is created for topics: it picks up copies of messages from them and passes them to the function for processing. The trigger must be in the same cloud as the device or register as the topic it reads messages from.
You can create a trigger:
-
For a standard topic implemented by the service.
Warning
You can't create a trigger for the
$monitoring/<device ID>/json
topic. -
For a topic with any subtopics and wildcards.
-
For an alias of a topic.
A trigger for Yandex IoT Core needs a service account to invoke the function.
Roles required for the proper operation of a trigger for Yandex IoT Core
- To create a trigger, you need a permission for a service account that runs the trigger executing the operation. This permission is included in the roles iam.serviceAccounts.user, editor, and higher.
- To run a trigger, the service account needs the
serverless.functions.invoker
role for the folder containing the function called by the trigger.
Learn more about access management.
Trigger message format Yandex IoT Core
Before the message is copied to a function, the trigger converts it to the following format:
{
"messages": [
{
"event_metadata": {
"event_id": "2153b5d2-c6af-4c69-a28d-74ce965b7613",
"event_type": "yandex.cloud.events.iot.IoTMessage",
"created_at": "2019-09-25T15:51:17.872320525Z"
},
"details": {
"registry_id": "arenou2oj4ct42eq8g3n",
"device_id": "areqjd6un3afc3cefcvm",
"mqtt_topic": "$devices/areqjd6un3afc3cefcvm/events",
"payload": "VGVzdCA0"
}
},
{
"event_metadata": {
"event_id": "2153b5d2-c6af-4c69-a28d-74ce965b7613",
"event_type": "yandex.cloud.events.iot.IoTMessage",
"created_at": "2019-09-25T15:51:17.872320525Z"
},
"details": {
"registry_id": "arenou2oj4ct42eq8g3n",
"device_id": "areqjd6un3afc3cefcvm",
"mqtt_topic": "$devices/areqjd6un3afc3cefcvm/events",
"payload": "VGVzdCA0"
}
}
]
}