發佈/訂閱政策範例 - AWS IoT Core

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

發佈/訂閱政策範例

您使用的政策取決於您連接的方式 AWS IoT Core。您可以使 AWS IoT Core 用 MQTT 用戶端、HTTP 或進行連線。 WebSocket當您使用 MQTT 用戶端連接,必須使用 X.509 憑證進行驗證。當您透過 HTTP 或 WebSocket 通訊協定進行連線時,您正在使用簽名版本 4 和 Amazon Cognito 進行驗證。

注意

對於已註冊的裝置,建議您使用 Connect 動作的物件政策變數,並將物件附加至用於連線的主體。

在 MQTT 和 AWS IoT Core 政策中使用萬用字元

MQTT 和 AWS IoT Core 政策具有不同的萬用字元,您應該在仔細考慮之後選擇它們。在 MQTT 中,萬用字元+#用於 MQTT 主題篩選器,以訂閱多個主題名稱。 AWS IoT Core 政策使用*?做為萬用字元,並遵循 IAM 政策的慣例。在政策文件中,* 代表任意字元組合,? 則代表任何單一字元。在政策文件中,MQTT 萬用字元 +# 視為沒有特殊含義的字元。若要在政策中的 resource 屬性描述多個主題名稱和主題篩選條件,請使用 *? 萬用字元代替 MQTT 萬用字元。

當您選擇要在策略文件中使用的萬用字元時,請考慮該*字元不限於單一主題層級。該+字元僅限於 MQTT 主題篩選器中的單一主題層級。要幫助將萬用字元規範限制為單一 MQTT 主題篩選條件層級,請考慮使用多個 ? 字元。更多有關在政策資源中使用萬用字元的資訊以及它們比對的更多範例,請參閱在資源 ARN 中使用萬用字元

下表顯示 MQTT 用戶端的 AWS IoT Core 政策中使用的不同萬用字元。

萬用字元 是 MQTT 萬用字元 MQTT 中的範例 為 AWS IoT Core 原則萬用字元 MQTT 用戶 AWS IoT Core 端政策中的範例
# some/# N/A
+ some/+/topic 不適用
* N/A

topicfilter/some/*/topic

topicfilter/some/sensor*/topic

? N/A

topic/some/?????/topic

topicfilter/some/sensor???/topic

向/從特定主題發佈、訂閱及接收訊息的政策

以下範例顯示已註冊和未註冊裝置向/從名為 "some_specific_topic" 的主題發佈、訂閱和接收訊息的情形。這些範例也突顯 PublishReceive 使用 "topic" 作為資源,以及 Subscribe 使用 "topicfilter" 作為資源。

Registered devices

針對在登 AWS IoT Core 錄中註冊的裝置,下列原則允許裝置與登錄中物件名稱相符的 clientId 連線。針對名為 "some_specific_topic" 的主題,它也提供 PublishSubscribeReceive 的許可。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/${iot:Connection.Thing.ThingName}" ], "Condition": { "Bool": { "iot:Connection.Thing.IsAttached": "true" } } }, { "Effect": "Allow", "Action": [ "iot:Publish" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/some_specific_topic" ] }, { "Effect": "Allow", "Action": [ "iot:Subscribe" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topicfilter/some_specific_topic" ] }, { "Effect": "Allow", "Action": [ "iot:Receive" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/some_specific_topic" ] } ] }
Unregistered devices

對於未在登 AWS IoT Core 錄中註冊的裝置,下列原則允許裝置使用用戶端 1、ClientD2 或 ClientId3 進行連線。針對名為 "some_specific_topic" 的主題,它也提供 PublishSubscribeReceive 的許可。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/clientId1", "arn:aws:iot:us-east-1:123456789012:client/clientId2", "arn:aws:iot:us-east-1:123456789012:client/clientId3" ] }, { "Effect": "Allow", "Action": [ "iot:Publish" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/some_specific_topic" ] }, { "Effect": "Allow", "Action": [ "iot:Subscribe" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topicfilter/some_specific_topic" ] }, { "Effect": "Allow", "Action": [ "iot:Receive" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/some_specific_topic" ] } ] }

向/從具有特定前綴主題發佈、訂閱及接收訊息的政策

以下範例顯示已註冊和未註冊裝置向/從具有 "topic_prefix" 前綴的主題發佈、訂閱和接收訊息的情形。

注意

請注意此範例中萬用字元*的使用方式。雖然在單一陳述式中提供多個主題名稱的權限很有用,但*是對裝置提供超過所需權限,可能會導致意想不到的後果。因此,我們建議您只*在仔細考慮之後才使用萬用字元。

Registered devices

針對在登 AWS IoT Core 錄中註冊的裝置,下列原則允許裝置與登錄中物件名稱相符的 clientId 連線。針對以 "topic_prefix" 為前綴的主題,它也提供 PublishSubscribeReceive 的許可。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/${iot:Connection.Thing.ThingName}" ], "Condition": { "Bool": { "iot:Connection.Thing.IsAttached": "true" } } }, { "Effect": "Allow", "Action": [ "iot:Publish", "iot:Receive" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/topic_prefix*" ] }, { "Effect": "Allow", "Action": [ "iot:Subscribe" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topicfilter/topic_prefix*" ] } ] }
Unregistered devices

對於未在登 AWS IoT Core 錄中註冊的裝置,下列原則允許裝置使用用戶端 1、ClientD2 或 ClientId3 進行連線。它也為以 "topic_prefix" 為前綴的主題提供 PublishSubscribeReceive 的許可。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/clientId1", "arn:aws:iot:us-east-1:123456789012:client/clientId2", "arn:aws:iot:us-east-1:123456789012:client/clientId3" ] }, { "Effect": "Allow", "Action": [ "iot:Publish", "iot:Receive" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/topic_prefix*" ] }, { "Effect": "Allow", "Action": [ "iot:Subscribe" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topicfilter/topic_prefix*" ] } ] }

向/從各項裝置特定主題發佈、訂閱及接收訊息的政策

以下範例顯示已註冊和未註冊裝置向/從特定裝置專屬的主題發佈、訂閱和接收訊息的情形。

Registered devices

針對在登 AWS IoT Core 錄中註冊的裝置,下列原則允許裝置與登錄中物件名稱相符的 clientId 連線。它提供向物件特定主題 (sensor/device/${iot:Connection.Thing.ThingName}) 進行發佈的許可,以及從物件特定主題 (command/device/${iot:Connection.Thing.ThingName}) 進行訂閱和接收的許可。如果登錄中的物件名稱是「thing1」,則裝置將能夠發佈至「感測器/裝置/物件 1」主題。該設備還可以訂閱和接收主題「命令/設備/事物 1」。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/${iot:Connection.Thing.ThingName}" ], "Condition": { "Bool": { "iot:Connection.Thing.IsAttached": "true" } } }, { "Effect": "Allow", "Action": [ "iot:Publish" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/sensor/device/${iot:Connection.Thing.ThingName}" ] }, { "Effect": "Allow", "Action": [ "iot:Subscribe" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topicfilter/command/device/${iot:Connection.Thing.ThingName}" ] }, { "Effect": "Allow", "Action": [ "iot:Receive" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/command/device/${iot:Connection.Thing.ThingName}" ] } ] }
Unregistered devices

對於未在登 AWS IoT Core 錄中註冊的裝置,下列原則允許裝置使用用戶端 1、ClientD2 或 ClientId3 進行連線。它提供向用戶端特定主題 (sensor/device/${iot:ClientId}) 進行發佈的許可,以及從用戶端特定主題 (command/device/${iot:ClientId}) 進行訂閱和接收的許可。如果設備以 clientId 1 的身份連接 ClientID,它將能夠發布到主題「傳感器/設備/客戶端 1」。該設備還可以訂閱並從主題接收device/clientId1/command

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/clientId1", "arn:aws:iot:us-east-1:123456789012:client/clientId2", "arn:aws:iot:us-east-1:123456789012:client/clientId3" ] }, { "Effect": "Allow", "Action": [ "iot:Publish" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/sensor/device/${iot:Connection.Thing.ThingName}" ] }, { "Effect": "Allow", "Action": [ "iot:Subscribe" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topicfilter/command/device/${iot:Connection.Thing.ThingName}" ] }, { "Effect": "Allow", "Action": [ "iot:Receive" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/command/device/${iot:Connection.Thing.ThingName}" ] } ] }

向/從主題名稱中具有物件屬性的主題發佈、訂閱和接收訊息的政策

以下範例顯示已註冊裝置向/從名稱含有物件屬性的主題發佈、訂閱和接收訊息的情形。

注意

物件屬性僅存在於登 AWS IoT Core 錄中註冊的裝置。未註冊的裝置沒有對應的範例。

Registered devices

針對在登 AWS IoT Core 錄中註冊的裝置,下列原則允許裝置與登錄中物件名稱相符的 clientId 連線。它提供向主題 (sensor/${iot:Connection.Thing.Attributes[version]}) 進行發佈的許可,以及從主題名稱含有物件屬性的主題 (command/${iot:Connection.Thing.Attributes[location]}) 進行訂閱和接收的許可。如果註冊表中的事物名稱具有version=v1location=Seattle,則設備將能夠發布到主題「Sensor/V1」,並訂閱並從主題「命令/西雅圖」接收。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/${iot:Connection.Thing.ThingName}" ], "Condition": { "Bool": { "iot:Connection.Thing.IsAttached": "true" } } }, { "Effect": "Allow", "Action": [ "iot:Publish" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/sensor/${iot:Connection.Thing.Attributes[version]}" ] }, { "Effect": "Allow", "Action": [ "iot:Subscribe" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topicfilter/command/${iot:Connection.Thing.Attributes[location]}" ] }, { "Effect": "Allow", "Action": [ "iot:Receive" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/command/${iot:Connection.Thing.Attributes[location]}" ] } ] }
Unregistered devices

因為物件屬性僅存在於登 AWS IoT Core 錄中註冊的裝置,因此沒有對應的未註冊物件範例。

拒絕向特定主題名稱的子主題進行發佈的政策

以下範例顯示已註冊和未註冊裝置向特定子主題以外的所有主題發佈訊息的情形。

Registered devices

針對在登 AWS IoT Core 錄中註冊的裝置,下列原則允許裝置與登錄中物件名稱相符的 clientId 連線。它提供向所有以 "department/" 為前綴的主題進行發佈的許可,但未及於 "department/admins" 子主題。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/${iot:Connection.Thing.ThingName}" ], "Condition": { "Bool": { "iot:Connection.Thing.IsAttached": "true" } } }, { "Effect": "Allow", "Action": [ "iot:Publish" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/department/*" ] }, { "Effect": "Deny", "Action": [ "iot:Publish" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/department/admins" ] } ] }
Unregistered devices

對於未在登 AWS IoT Core 錄中註冊的裝置,下列原則允許裝置使用用戶端 1、ClientD2 或 ClientId3 進行連線。它提供向所有以 "department/" 為前綴的主題進行發佈的許可,但未及於 "department/admins" 子主題。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/clientId1", "arn:aws:iot:us-east-1:123456789012:client/clientId2", "arn:aws:iot:us-east-1:123456789012:client/clientId3" ] }, { "Effect": "Allow", "Action": [ "iot:Publish" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/department/*" ] }, { "Effect": "Deny", "Action": [ "iot:Publish" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:topic/department/admins" ] } ] }

拒絕從特定主題名稱的子主題進行接收的政策

以下範例顯示已註冊和未註冊裝置從特定子主題以外所有具特定前綴主題訂閱和接收訊息的情形。

Registered devices

針對在登 AWS IoT Core 錄中註冊的裝置,下列原則允許裝置與登錄中物件名稱相符的 clientId 連線。此政策允許裝置訂閱任何前綴為 "topic_prefix" 的主題。藉由在 iot:Receive 的陳述式中使用,NotResource我們允許裝置接收所有來自其已訂閱主題的訊息,但前綴為 "topic_prefix/restricted" 的主題除外。例如在此政策中,裝置可以訂閱 "topic_prefix/topic1" 甚至 "topic_prefix/restricted",但是它們只會接收來自 "opic_prefix/topic1" 主題的訊息,且不會接收來自 "topic_prefix/restricted" 主題的訊息。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/${iot:Connection.Thing.ThingName}" ], "Condition": { "Bool": { "iot:Connection.Thing.IsAttached": "true" } } }, { "Effect": "Allow", "Action": "iot:Subscribe", "Resource": "arn:aws:iot:us-east-1:123456789012:topicfilter/topic_prefix/*" }, { "Effect": "Allow", "Action": "iot:Receive", "NotResource": "arn:aws:iot:us-east-1:123456789012:topic/topic_prefix/restricted/*" } ] }
Unregistered devices

對於未在登 AWS IoT Core 錄中註冊的裝置,下列原則允許裝置使用用戶端 1、ClientD2 或 ClientId3 進行連線。此政策允許裝置訂閱任何前綴為 "topic_prefix" 的主題。藉由在 iot:Receive 的陳述式中使用 NotResource,我們允許裝置接收所有來自其已訂閱主題的訊息,但前綴為 "topic_prefix/restricted" 的主題除外。例如,使用此策略,設備可以訂閱「topic_首碼/主題1」,甚至「主題 _ 首碼/受限制」。但是,他們只會接收來自主題「主題/主題 1」的消息,並且不會收到來自「主題 _ 首碼/受限制」主題的消息。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/clientId1", "arn:aws:iot:us-east-1:123456789012:client/clientId2", "arn:aws:iot:us-east-1:123456789012:client/clientId3" ] }, { "Effect": "Allow", "Action": "iot:Subscribe", "Resource": "arn:aws:iot:us-east-1:123456789012:topicfilter/topic_prefix/*" }, { "Effect": "Allow", "Action": "iot:Receive", "NotResource": "arn:aws:iot:us-east-1:123456789012:topic/topic_prefix/restricted/*" } ] }

從使用 MQTT 萬用字元的主題進行訂閱的政策

MQTT 萬用字元 + 和 # 會被視為常值字串,但在原則中使用時不會被視為萬用字元。 AWS IoT Core 在 MQTT 中,僅在訂閱主題篩選條件時才會將 + 和 # 視為萬用字元,但在所有其他情況下視為常值字串。我們建議您在仔細考量之後,僅使用這些 MQTT 萬用字元作為 AWS IoT Core 政策的一部分。

以下顯示在原則中使用 MQTT 萬用字元的已註冊和未註冊物件的範例。 AWS IoT Core 這些萬用字元會視為常值字串。

Registered devices

針對在登 AWS IoT Core 錄中註冊的裝置,下列原則允許裝置與登錄中物件名稱相符的 clientId 連線。此政策允許裝置訂閱 "department/+/employees" 和 "location/#" 主題。由於 + 和 #會被視為原則中的 AWS IoT Core 文字字串,因此裝置可以訂閱主題「部門 /+/員工」,但不能訂閱「部門/工程/員工」主題。同樣,裝置可以訂閱 "location/#" 主題,但不能訂閱 "location/Seattle" 主題。但是,一旦裝置訂閱了 "department/+/employees" 主題,此政策將允許其接收來自 "department/engineering/employees" 主題的訊息。同樣,一旦裝置訂閱了 "location/#" 主題,其也將接收來自 "location/Seattle" 主題的訊息。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/${iot:Connection.Thing.ThingName}" ], "Condition": { "Bool": { "iot:Connection.Thing.IsAttached": "true" } } }, { "Effect": "Allow", "Action": "iot:Subscribe", "Resource": "arn:aws:iot:us-east-1:123456789012:topicfilter/department/+/employees" }, { "Effect": "Allow", "Action": "iot:Subscribe", "Resource": "arn:aws:iot:us-east-1:123456789012:topicfilter/location/#" }, { "Effect": "Allow", "Action": "iot:Receive", "Resource": "arn:aws:iot:us-east-1:123456789012:topic/*" } ] }
Unregistered devices

對於未在登 AWS IoT Core 錄中註冊的裝置,下列原則允許裝置使用用戶端 1、ClientD2 或 ClientId3 進行連線。此政策允許裝置訂閱 "department/+/employees" 和 "location/#" 主題。由於 + 和 #會被視為原則中的 AWS IoT Core 文字字串,因此裝置可以訂閱主題「部門 /+/員工」,但不能訂閱「部門/工程/員工」主題。同樣,裝置可以訂閱 "location/#" 主題,但不能訂閱 "location/Seattle"。但是,一旦裝置訂閱了 "department/+/employees" 主題,此政策將允許其接收來自 "department/engineering/employees" 主題的訊息。同樣,一旦裝置訂閱了 "location/#" 主題,其也將接收來自 "location/Seattle" 主題的訊息。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": [ "arn:aws:iot:us-east-1:123456789012:client/clientId1", "arn:aws:iot:us-east-1:123456789012:client/clientId2", "arn:aws:iot:us-east-1:123456789012:client/clientId3" ] }, { "Effect": "Allow", "Action": "iot:Subscribe", "Resource": "arn:aws:iot:us-east-1:123456789012:topicfilter/department/+/employees" }, { "Effect": "Allow", "Action": "iot:Subscribe", "Resource": "arn:aws:iot:us-east-1:123456789012:topicfilter/location/#" }, { "Effect": "Allow", "Action": "iot:Receive", "Resource": "arn:aws:iot:us-east-1:123456789012:topic/*" } ] }

HTTP 和用 WebSocket戶端的政策

當您透過 HTTP 或 WebSocket 通訊協定進行連線時,您正在使用簽名版本 4 和 Amazon Cognito 進行驗證。Amazon Cognito 身分可以是已驗證或未驗證的身分。已驗證的身分屬於已由任何支援的身分提供者驗證的使用者。未驗證的身分通常屬於未向身分提供者驗證身分的訪客使用者。Amazon Cognito 提供唯一的識別碼和 AWS 登入資料,以支援未經驗證的身分。如需詳細資訊,請參閱 使用 Amazon Cognito 身分授權

對於下列操作,請 AWS IoT Core 使用透過 AttachPolicy API 連接至 Amazon Cognito 身分識別的 AWS IoT Core 政策。這會將附加至 Amazon Cognito 身分集區的許可範圍降低使用已驗證身分的範圍。

  • iot:Connect

  • iot:Publish

  • iot:Subscribe

  • iot:Receive

  • iot:GetThingShadow

  • iot:UpdateThingShadow

  • iot:DeleteThingShadow

這表示 Amazon Cognito 身分需要 IAM 角色政策和政策的 AWS IoT Core 許可。您可以透過 AWS IoT Core AttachPolicy API 將 IAM 角色政策附加到集區,並將 AWS IoT Core 政策附加到 Amazon Cognito 身分識別。

已驗證和未驗證的使用者是不同的身分類型。如果您未將 AWS IoT 政策附加到 Amazon Cognito 身分識別,則經過驗證的使用者會失敗授權, AWS IoT 且無法存取 AWS IoT 資源和動作。

注意

對於其他 AWS IoT Core 操作或未驗證身分, AWS IoT Core 不會縮小連接到 Amazon Cognito 身分集區角色的許可範圍。對於已驗證和未驗證兩者的身分而言,這是我們針對連接至 Amazon Cognito 集區角色的政策,所提供的最寬容建議。

HTTP

若要允許未驗證 Amazon Cognito 身分透過 HTTP 對 Amazon Cognito 身分特定的主題發佈訊息,請將下列 IAM 政策連接至 Amazon Cognito 身分集區角色:

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Publish", ], "Resource": ["arn:aws:iot:us-east-1:123456789012:topic/${cognito-identity.amazonaws.com:sub}"] } ] }

若要允許經過驗證的使用者,請使用 API 將上述政策附加到 Amazon Cognito 身分集區角色和 Amazon Cognito 身分識別。 AWS IoT Core AttachPolicy

注意

授權 Amazon Cognito 身分時,請同時 AWS IoT Core 考慮這兩個政策,並授予指定的最低權限。只有在兩個政策都允許要求的動作時,才會允許執行動作。如果兩個政策都禁止動作,則該動作為未授權。

MQTT

若要允許未經驗證的 Amazon Cognito 身分針對您帳戶中的 Amazon Cognito 身分特定主題發佈 MQTT 訊息,請將以下 IAM 政策附加到 Amazon Cognito 身分集區角色: WebSocket

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Publish" ], "Resource": ["arn:aws:iot:us-east-1:123456789012:topic/${cognito-identity.amazonaws.com:sub}"] }, { "Effect": "Allow", "Action": [ "iot:Connect" ], "Resource": ["arn:aws:iot:us-east-1:123456789012:client/${cognito-identity.amazonaws.com:sub}"] } ] }

若要允許經過驗證的使用者,請使用 API 將上述政策附加到 Amazon Cognito 身分集區角色和 Amazon Cognito 身分識別。 AWS IoT Core AttachPolicy

注意

授權 Amazon Cognito 身分時,請 AWS IoT Core 考慮兩者並授與指定的最低權限。只有在兩個政策都允許要求的動作時,才會允許執行動作。如果兩個政策都禁止動作,則該動作為未授權。