ステップ 1: AWS IoT ポリシーの作成 - AWS IoT SiteWise

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

ステップ 1: AWS IoT ポリシーの作成

この手順では、このチュートリアルで使用されているリソースに AWS IoT Things AWS IoT がアクセスできるようにするポリシーを作成します。

AWS IoT ポリシーを作成するには
  1. AWS Management Consoleにサインインします。

  2. AWSAWS IoT SiteWise サポートされているリージョンを確認してください。必要に応じて、これらのサポートされているいずれかのリージョンに切り替えます。

  3. AWS IoT コンソールに移動します。[デバイスのConnect] ボタンが表示されたら、それを選択します。

  4. 左のナビゲーションペインで、[安全性] を選択し、[ポリシー] を選択します。

  5. [作成] を選択します。

  6. AWS IoT ポリシーの名前 (例:SiteWiseTutorialDevicePolicy) を入力します。

  7. [ポリシードキュメント][JSON] を選択して JSON 形式で次のポリシーを入力します。お客様のリージョンとアカウント ID で regionaccount-id を置き換えます (us-east-1123456789012 など)。

    { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "iot:Connect", "Resource": "arn:aws:iot:region:account-id:client/SiteWiseTutorialDevice*" }, { "Effect": "Allow", "Action": "iot:Publish", "Resource": [ "arn:aws:iot:region:account-id:topic/$aws/things/${iot:Connection.Thing.ThingName}/shadow/update", "arn:aws:iot:region:account-id:topic/$aws/things/${iot:Connection.Thing.ThingName}/shadow/delete", "arn:aws:iot:region:account-id:topic/$aws/things/${iot:Connection.Thing.ThingName}/shadow/get" ] }, { "Effect": "Allow", "Action": "iot:Receive", "Resource": [ "arn:aws:iot:region:account-id:topic/$aws/things/${iot:Connection.Thing.ThingName}/shadow/update/accepted", "arn:aws:iot:region:account-id:topic/$aws/things/${iot:Connection.Thing.ThingName}/shadow/delete/accepted", "arn:aws:iot:region:account-id:topic/$aws/things/${iot:Connection.Thing.ThingName}/shadow/get/accepted", "arn:aws:iot:region:account-id:topic/$aws/things/${iot:Connection.Thing.ThingName}/shadow/update/rejected", "arn:aws:iot:region:account-id:topic/$aws/things/${iot:Connection.Thing.ThingName}/shadow/delete/rejected" ] }, { "Effect": "Allow", "Action": "iot:Subscribe", "Resource": [ "arn:aws:iot:region:account-id:topicfilter/$aws/things/${iot:Connection.Thing.ThingName}/shadow/update/accepted", "arn:aws:iot:region:account-id:topicfilter/$aws/things/${iot:Connection.Thing.ThingName}/shadow/delete/accepted", "arn:aws:iot:region:account-id:topicfilter/$aws/things/${iot:Connection.Thing.ThingName}/shadow/get/accepted", "arn:aws:iot:region:account-id:topicfilter/$aws/things/${iot:Connection.Thing.ThingName}/shadow/update/rejected", "arn:aws:iot:region:account-id:topicfilter/$aws/things/${iot:Connection.Thing.ThingName}/shadow/delete/rejected" ] }, { "Effect": "Allow", "Action": [ "iot:GetThingShadow", "iot:UpdateThingShadow", "iot:DeleteThingShadow" ], "Resource": "arn:aws:iot:region:account-id:thing/SiteWiseTutorialDevice*" } ] }

    このポリシーにより、 AWS IoT デバイスは接続を確立し、MQTT メッセージを使用してデバイスシャドウと通信できるようになります。MQTT メッセージについて詳しくは、「MQTT とは?」を参照してください。 。デバイスシャドウを操作するには、で始まるトピックの AWS IoT MQTT メッセージをパブリッシュおよび受信します。$aws/things/thing-name/shadow/このポリシーには、という Thing ポリシー変数が組み込まれています。${iot:Connection.Thing.ThingName}この変数は、各トピック内の接続されている Thing の名前を置き換えます。iot:Connectこのステートメントは、接続を確立できるデバイスに制限を設け、Thing ポリシー変数がで始まる名前だけに置き換えられるようにしています。SiteWiseTutorialDevice

    詳細については、[AWS IoT Developer Guide] (デベロッパーガイド) の[Thing policy variables] (シングポリシー変数) を参照してください。

    注記

    このポリシーは、名前が SiteWiseTutorialDevice で始まるモノに適用されます。モノに別の名前を使用するには、それに応じてポリシーを更新する必要があります。

  8. [作成] を選択します。