View a markdown version of this page

受管整合通知 - 的受管整合 AWS IoT Device Management

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

受管整合通知

受管整合通知提供來自裝置的更新和主要洞見。通知包括連接器事件、裝置命令、生命週期事件、OTA Over-the-Air) 更新和錯誤報告。這些洞見提供可行的資訊,以建立自動化工作流程、採取立即動作或存放事件資料進行故障診斷。

目前,僅支援 Amazon Kinesis 資料串流做為受管整合通知的目的地。您必須先設定 Amazon Kinesis 資料串流,並允許受管整合存取資料串流,再設定通知。

為通知設定 Amazon Kinesis

若要設定 Amazon Kinesis for Managed Integrations 通知,請遵循下列步驟:

步驟 1:建立 Amazon Kinesis 資料串流

Amazon Kinesis Data Stream 可以即時擷取大量資料、長期存放資料,並讓資料可供應用程式使用。

建立 Amazon Kinesis 資料串流

步驟 2:建立許可政策

建立允許受管整合存取 Kinesis 資料串流的許可政策。

建立許可政策
  • 若要建立許可政策,請複製以下政策,並遵循使用 JSON 編輯器建立政策中概述的步驟

    JSON
    { "Version":"2012-10-17", "Statement": [ { "Action": "kinesis:PutRecord", "Resource": "*", "Effect": "Allow" } ] }

開啟 IAM 儀表板,然後按一下角色。

導覽至 IAM 儀表板
  • 開啟 IAM 儀表板,然後按一下角色。

    如需詳細資訊,請參閱AWS Identity and Access Management《 使用者指南》中的建立 IAM 角色。

步驟 4:使用自訂信任政策

您可以使用自訂信任政策,授予受管整合對 Kinesis 資料串流的存取權。

使用自訂信任政策
  • 建立新的角色,然後選擇自訂信任政策。按一下下一步。

    下列政策允許 受管整合擔任 角色,而 Condition陳述式有助於防止混淆代理人問題。

    JSON
    { "Version":"2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "iotmanagedintegrations.amazonaws.com" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "aws:SourceAccount": "123456789012" }, "ArnLike": { "aws:SourceArn": "arn:aws:iotmanagedintegrations:ca-central-1:123456789012:*" } } } ] }

步驟 5:套用您的許可政策

將您在步驟 2 中建立的許可政策新增至角色。

新增許可政策
  • 在新增許可頁面上,搜尋並新增您在步驟 2 中建立的許可政策。按一下下一步。

步驟 6:輸入角色名稱

  • 輸入角色名稱,然後按一下建立角色。

設定受管整合通知

若要設定受管整合通知,請遵循下列步驟:

步驟 1:授予使用者呼叫 CreateDestination API 的許可

  • 授予使用者呼叫 CreateDestination API 的許可

    下列政策定義使用者呼叫 CreateDestination API 的需求。

    請參閱《 AWS Identity and Access Management 使用者指南》中的授予使用者將角色傳遞至 AWS 服務的許可,以取得受管整合的傳遞許可。

    JSON
    { "Version":"2012-10-17", "Statement":[ { "Effect":"Allow", "Action":"iam:PassRole", "Resource":"arn:aws:iam::123456789012:role/ROLE_CREATED_IN_PREVIOUS_STEP", "Condition":{ "StringEquals":{ "iam:PassedToService":"iotmanagedintegrations.amazonaws.com" } } }, { "Effect":"Allow", "Action":"iotmanagedintegrations:CreateDestination", "Resource":"*" } ] }

步驟 2:呼叫 CreateDestination API

  • 呼叫 CreateDestination API

    在您建立 Amazon Kinesis 資料串流和串流存取角色之後,請呼叫 CreateDestination API 來建立通知目的地,以便將通知路由到該目的地。針對 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

  • 呼叫 CreateNotificationConfiguration API

    最後,使用 CreateNotificationConfiguration API 建立通知組態,將所選事件類型路由到 Kinesis 資料串流所代表的目的地。在 DestinationName 參數中,使用與最初呼叫 CreateDestination API 時相同的目的地名稱。

    { "EventType": "DEVICE_EVENT" "DestinationName" // This name has to be identical to the name in createDestination API "ClientToken": "string" }

使用受管整合監控的事件類型

以下是使用受管整合通知監控的事件類型:

  • DEVICE_COMMAND

    • SendManagedThingCommand API 命令的狀態。有效值是 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

    • 來自 Web 即時通訊 (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

    反映裝置生命週期的狀態變更 (包括加入狀態和連線/中斷連線狀態)。

    • 加入狀態更新事件。

      { "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

    • 當cloud-to-cloud(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會在可針對請求解析時包含在內。承載會省略沒有值的欄位。