设备注册Enrich活动 - AWS IoT Analytics
AWS 文档中描述的 AWS 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 AWS 服务入门

设备注册Enrich活动

deviceRegistryEnrich 活动使您能够从 AWS IoT 设备注册到您的消息有效负载。例如,给定了以下 消息:

{ "temp": 50, "hum": 40, "device" { "thingName": "my-thing" } }

和类似下面这样的 deviceRegistryEnrich 活动:

{ "deviceRegistryEnrich": { "name": "MyDeviceRegistryEnrichActivity", "attribute": "metadata", "thingName": "device.thingName", "roleArn": "arn:aws:iam::<your-account-number>:role:MyEnrichRole", "next": "MyDatastoreActivity" } }

输出消息现在看起来像此示例。

{ "temp" : 50, "hum" : 40, "device" { "thingName" : "my-thing" }, "metadata" : { "defaultClientId": "my-thing", "thingTypeName": "my-thing", "thingArn": "arn:aws:iot:us-east-1:<your-account-number>:thing/my-thing", "version": 1, "thingName": "my-thing", "attributes": {}, "thingId": "aaabbbccc-dddeeef-gghh-jjkk-llmmnnoopp" } }

您必须在活动定义的 roleArn 字段中指定已附加适当权限的角色。该角色必须具有权限策略,看起来像以下示例。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:DescribeThing" ], "Resource": [ "arn:aws:iot:<region>:<account-id>:thing/<thing-name>" ] } ] }

和类似如下的信任策略:

{ "Version": "2012-10-17", "Statement": [ { "Sid": "", "Effect": "Allow", "Principal": { "Service": "iotanalytics.amazonaws.com" }, "Action": [ "sts:AssumeRole" ] } ] }