本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
托管集成通知
托管集成通知可提供来自设备的更新和关键见解。通知包括连接器事件、设备命令、生命周期事件、OTA (Over-the-Air) 更新和错误报告。这些见解提供了可操作的信息,用于创建自动化工作流程、立即采取行动或存储事件数据以进行故障排除。
目前,仅支持 Amazon Kinesis 数据流作为托管集成通知的目的地。在设置通知之前,您需要先设置 Amazon Kinesis 数据流并允许托管集成访问该数据流。
设置 Amazon Kinesis 以接收通知
亚马逊 Kinesis 设置步骤
要设置用于托管集成的 Amazon Kinesis 通知,请按照以下步骤操作:
步骤 1:创建 Amazon Kinesis 数据流
Amazon Kinesis 数据流可以实时摄取大量数据,持久存储数据,并使数据可供应用程序使用。
创建 Amazon Kinesis 数据流
-
要创建 Kinesis 数据流,请按照创建和管理 Kinesis 数据流中概述的步骤进行操作。
步骤 2:创建权限策略
创建权限策略,允许托管集成访问您的 Kinesis 数据流。
创建权限策略
-
要创建权限策略,请复制以下策略,然后按照使用 JSON 编辑器创建策略中概述的步骤进行操作
步骤 3:导航到 IAM 控制面板并选择角色
打开 IAM 控制面板,然后单击 “角色”。
导航到 IAM 控制面板
-
打开 IAM 控制面板,然后单击 “角色”。
有关更多信息,请参阅《AWS Identity and Access Management用户指南》中的 IAM 角色创建。
步骤 4:使用自定义信任策略
您可以使用自定义信任策略向托管集成授予对 Kinesis 数据流的访问权限。
使用自定义信任策略
-
创建新角色并选择自定义信任策略。单击 “下一步”。
以下政策允许托管集成担任该角色,该
Condition声明有助于防止混淆副手问题。
第 5 步:应用您的权限策略
将您在步骤 2 中创建的权限策略添加到角色中。
添加权限策略
-
在添加权限页面上,搜索并添加您在步骤 2 中创建的权限策略。单击 “下一步”。
步骤 6:输入角色名称
-
输入角色名称,然后单击 “创建角色”。
设置托管集成通知
通知设置步骤
要设置托管集成通知,请按照以下步骤操作:
步骤 1:向用户授予调用 CreateDestination API 的权限
-
向用户授予调用
CreateDestinationAPI 的权限以下策略定义了用户调用 CreateDestinationAPI 的要求。
要获取托管集成的passrole权限,请参阅AWS Identity and Access Management用户指南中的授予用户将角色传递给 AWS 服务的权限。
第 2 步:调用 CreateDestination API
-
调用
CreateDestinationAPI创建 Amazon Kinesis 数据流和流访问角色后,调用 CreateDestinationAPI 来创建通知将发送到的通知目的地。对于
DeliveryDestinationArn参数,请使用您的新 Amazon Kinesis 数据流中的。arn{ "DeliveryDestinationArn": "Your Kinesis arn" "DeliveryDestinationType": "KINESIS" "Name": "DestinationName" "ClientToken":"string""RoleArn": "arn:aws:iam::accountID:role/ROLE_CREATED_IN_PREVIOUS_STEP" }注意
ClientToken是一个等性标记。如果您使用相同的客户端令牌和参数重试最初成功完成的请求,则重试尝试将成功而无需执行任何进一步的操作。
第 3 步:调用 CreateNotificationConfiguration API
-
调用
CreateNotificationConfigurationAPI最后,使用 CreateNotificationConfigurationAPI 创建通知配置,将所选事件类型路由到由 Kinesis 数据流表示的目的地。在
DestinationName参数中,使用与最初调用CreateDestinationAPI 时相同的目标名称。{ "EventType": "DEVICE_EVENT" "DestinationName" // This name has to be identical to the name in createDestination API "ClientToken":"string"}
使用托管集成监控的事件类型
以下是使用托管集成通知监控的事件类型:
-
DEVICE_COMMAND-
SendManagedThingCommandAPI 命令的状态。有效值为
succeeded或failed。{ "version":"0", "messageId":"6a7e8feb-b491-4cf7-a9f1-bf3703467718", "messageType":"DEVICE_COMMAND", "source":"aws.iotmanagedintegrations", "customerAccountId":"123456789012", "timestamp":"1731623291671", "region":"ca-central-1", "resources":[ "arn:aws:iotmanagedintegrations:ca-central-1:123456789012:managed-thing/6a7e8feb-b491-4cf7-a9f1-bf3703467718" ], "payload":{ "traceId":"1234567890abcdef0", "receivedAt":"2017-12-22T18:43:48Z", "executedAt":"2017-12-22T18:43:48Z", "result":"failed" } }
-
-
DEVICE_COMMAND_REQUEST-
来自网络 Real-Time 通信 (WebRTC) 的命令请求。
WebRTC标准允许两个对等方之间进行通信。这些对等体可以传输实时视频、音频和任意数据。托管集成支持WebRTC,以便在客户的移动应用程序和最终用户的设备之间实现这些类型的流式传输。有关 WebRTC 标准的更多信息,请参阅 WebRTC。
{ "version":"0", "messageId":"6a7e8feb-b491-4cf7-a9f1-bf3703467718", "messageType":"DEVICE_COMMAND_REQUEST", "source":"aws.iotmanagedintegrations", "customerAccountId":"123456789012", "timestamp":"1731623291671", "region":"ca-central-1", "resources":[ "arn:aws:iotmanagedintegrations:ca-central-1:123456789012:managed-thing/6a7e8feb-b491-4cf7-a9f1-bf3703467718" ], "payload":{ "endpoints":[{ "endpointId":"1", "capabilities":[{ "id":"aws.DoorLock", "name":"Door Lock", "version":"1.0" }] }] } }
-
-
DEVICE_DISCOVERY_STATUS-
设备的发现状态。
{ "version":"0", "messageId":"6a7e8feb-b491-4cf7-a9f1-bf3703467718", "messageType":"DEVICE_DISCOVERY_STATUS", "source":"aws.iotmanagedintegrations", "customerAccountId":"123456789012", "timestamp":"2017-12-22T18:43:48Z", "region":"ca-central-1", "resources":[ "arn:aws:iotmanagedintegrations:ca-central-1:123456789012:managed-thing/6a7e8feb-b491-4cf7-a9f1-bf3703467718" ], "payload":{ "deviceCount": 1, "deviceDiscoveryId": "123", "status": "SUCCEEDED" } }
-
-
DEVICE_EVENT-
设备事件发生的通知。
{ "version":"1.0", "messageId":"2ed545027bd347a2b855d28f94559940", "messageType":"DEVICE_EVENT", "source":"aws.iotmanagedintegrations", "customerAccountId":"123456789012", "timestamp":"1731630247280", "resources":[ "/quit/1b15b39992f9460ba82c6c04595d1f4f" ], "payload":{ "iotMiArrivalTimestamp":"2026-06-26T21:28:14.697Z", "endpoints":[{ "endpointId":"1", "capabilities":[{ "id":"aws.DoorLock", "name":"Door Lock", "version":"1.0", "properties":[{ "name":"ActuatorEnabled", "value":"true" }] }] }] } }DEVICE_EVENT有效载荷包含以下字段:-
iotMiArrivalTimestamp,字符串 (ISO 8601):表示设备何时将设备事件发布到托管集成的时间戳。使用此字段来确定从设备生成事件到托管集成收到事件之间的延迟。 -
endpoints:设备端点列表及其更新的功能属性。
外部邮件信封中的
timestamp字段表示通知何时发送到 Kinesis。有效负载iotMiArrivalTimestamp中的表示事件何时到达托管集成。如果在事件到达和通知发送之间存在处理延迟,则这两个时间戳可能会有所不同。 -
-
-
DEVICE_LIFE_CYCLE反映设备生命周期状态的变化(包括入职状态和 connected/disconnected 状态)。
-
入职状态更新事件。
{ "version": "1.0.0", "messageId": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6", "messageType": "DEVICE_LIFE_CYCLE", "source": "aws.iotmanagedintegrations", "customerAccountId": "123456789012", "timestamp": "2024-11-14T19:55:57.568284645Z", "region": "ca-central-1", "resources": [ "arn:aws:iotmanagedintegrations:ca-central-1:123456789012:managed-thing/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6" ], "payload": { "deviceDetails": { "id": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6", "arn": "arn:aws:iotmanagedintegrations:ca-central-1:123456789012:managed-thing/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6", "createdAt": "2024-11-14T19:55:57.515841147Z", "updatedAt": "2024-11-14T19:55:57.515841559Z" }, "status": "UNCLAIMED" } } -
设备已连接状态事件。
{ "version": "1.0", "messageId": "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", "messageType": "DEVICE_LIFE_CYCLE", "source": "aws.iotmanagedintegrations", "customerAccountId": "123456789012", "timestamp": "2024-11-14T19:55:57.568284645Z", "region": "ca-central-1", "resources": [ "arn:aws:iotmanagedintegrations:ca-central-1:123456789012:managed-thing/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6" ], "payload": { "managedThingId": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6", "managedThingArn": "arn:aws:iotmanagedintegrations:ca-central-1:123456789012:managed-thing/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6", "clientId": "iotmi-example-client-id", "timestamp": "1768000475344", "eventType": "connected", "sessionIdentifier": "q1w2e3r4-t5y6-u7i8-o9p0-a1s2d3f4g5h6", "principalIdentifier": "z1x2c3v4b5n6m7a8s9d0f1g2h3j4k5l6p7o8i9u0y1t2r3e4w5q6a7z8x9c0v1b2", "ipAddress": "192.0.2.100", "versionNumber": "0" } } -
设备已断开连接状态事件。
{ "version": "1.0", "messageId": "b2n3m4a5-s6d7-f8g9-h0j1-k2l3z4x5c6v7", "messageType": "DEVICE_LIFE_CYCLE", "source": "aws.iotmanagedintegrations", "customerAccountId": "123456789012", "timestamp": "2024-11-14T19:55:57.568284645Z", "region": "ca-central-1", "resources": [ "arn:aws:iotmanagedintegrations:ca-central-1:123456789012:managed-thing/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6" ], "payload": { "managedThingId": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6", "managedThingArn": "arn:aws:iotmanagedintegrations:ca-central-1:123456789012:managed-thing/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6", "clientId": "iotmi-example-client-id", "timestamp": "1768000492431", "eventType": "disconnected", "sessionIdentifier": "p9o8i7u6-y5t4-r3e2-w1q0-m9n8b7v6c5x4", "principalIdentifier": "a1s2d3f4g5h6j7k8l9z0x1c2v3b4n5m6q7w8e9r0t1y2u3i4o5p6a7s8d9f0g1h2", "versionNumber": "0", "disconnectReason": "CLIENT_INITIATED_DISCONNECT" } }
-
-
DEVICE_OTA-
设备的 OTA 通知。
{ "version": "1.0.0", "messageId": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6", "messageType": "DEVICE_OTA", "source": "aws.iotmanagedintegrations", "customerAccountId": "123456789012", "timestamp": "2024-11-14T19:55:57.568284645Z", "region": "ca-central-1", "resources": [ "arn:aws:iotmanagedintegrations:ca-central-1:123456789012:managed-thing/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6", "arn:aws:iotmanagedintegrations:ca-central-1:123456789012:managed-thing/b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7", "arn:aws:iotmanagedintegrations:ca-central-1:123456789012:managed-thing/c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8" ], "payload": { "operation": "CREATE_OTA", "otaTaskId": "ota-job-abc123def456", "status": "IN_PROGRESS", "otaType": "ONE_TIME" } }
-
-
DEVICE_STATE-
设备状态更新时的通知。
{ "messageType": "DEVICE_STATE", "source": "aws.iotmanagedintegrations", "customerAccountId": "123456789012", "timestamp": "1731623291671", "resources": [ "arn:aws:iotmanagedintegrations:ca-central-1:123456789012:managed-thing/61889008880012345678" ], "payload": { "addedStates": { "endpoints": [{ "endpointId": "nonEndpointId", "capabilities": [{ "id": "aws.OnOff", "name": "On/Off", "version": "1.0", "properties": [{ "name": "OnOff", "value": { "propertyValue": "\"onoff\"", "lastChangedAt": "2024-06-11T01:38:09.000414Z" } } ]} ]} ]} } }
-
-
ACCOUNT_ASSOCIATION-
账户关联状态更改为 IN_PROGRESS 时的通知。
{ "version": "1.0.0", "messageId": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6", "messageType": "ACCOUNT_ASSOCIATION", "source": "aws.iotmanagedintegrations", "customerAccountId": "123456789012", "timestamp": "2026-01-20T23:59:34.009284802Z", "region": "ca-central-1", "resources": ["arn:aws:iotmanagedintegrations:ca-central-1:123456789012:account-association/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"], "payload": { "traceId": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6", "logLevel": "INFO", "resourceType": "account-association", "resourceId": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6", "connectorDestinationId": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6", "associationArn": "arn:aws:iotmanagedintegrations:ca-central-1:123456789012:account-association/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6", "state": "ASSOCIATION_IN_PROGRESS", "isServiceError": false, "isCustomerError": false, "details": "AccountAssociation State is updated to IN_PROGRESS during StartAccountAssociationRefresh" } } -
账户关联成功完成时的通知。
{ "version": "1.0.0", "messageId": "b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7", "messageType": "ACCOUNT_ASSOCIATION", "source": "aws.iotmanagedintegrations", "customerAccountId": "123456789012", "timestamp": "2026-01-20T23:59:44.672304821Z", "region": "ca-central-1", "resources": ["arn:aws:iotmanagedintegrations:ca-central-1:123456789012:account-association/b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7"], "payload": { "traceId": "b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7", "logLevel": "INFO", "resourceType": "account-association", "resourceId": "b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7", "connectorDestinationId": "b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7", "associationArn": "arn:aws:iotmanagedintegrations:ca-central-1:123456789012:account-association/b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7", "state": "ASSOCIATION_SUCCEEDED", "isServiceError": false, "isCustomerError": false, "details": "AccountAssociation has completed successfully" } }
-
-
CONNECTOR_ERROR_REPORT-
当云到云 (C2C) 连接器在代表您处理请求(例如命令或设备发现返回不成功响应)时报告错误,则会发送此通知。
{ "version": "1.0.0", "messageId": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6", "messageType": "CONNECTOR_ERROR_REPORT", "source": "aws.iotmanagedintegrations", "customerAccountId": "123456789012", "timestamp": "2026-01-20T23:59:34.009284802Z", "region": "ca-central-1", "resources": [ "arn:aws:iotmanagedintegrations:ca-central-1:123456789012:account-association/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6" ], "payload": { "statusCode": 0, "resourceType": "account-association", "resourceId": [ "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6" ], "associationArn": [ "arn:aws:iotmanagedintegrations:ca-central-1:123456789012:account-association/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6" ], "connectorDestinationId": "b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7", "connectorDeviceId": "connectorDeviceId11597664a", "operation": "AWS.SendCommand", "operationVersion": "1.0", "traceId": "f4be7a5d55d34cc=_1", "logLevel": "ERROR", "message": "AWS.SendCommand operation failed during asynchronous invocation of the connector: Connector response exception: responseCode=xxx, responseMessage=Mocking a ValidationException with error code xxx", "managedThingId": "c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8" } }当可以为请求解析该
managedThingId字段时,才会包含该字段。负载中将省略没有值的字段。
-