モノのポリシーの例 - AWS IoT Core

モノのポリシーの例

次のポリシーでは、AWS IoT Core を使用して認証するために使用されている証明書が、ポリシーが評価されているモノにアタッチされている場合に、デバイスの接続が許可されます。

JSON
{ "Version":"2012-10-17", "Statement":[ { "Effect":"Allow", "Action":["iot:Connect"], "Resource":[ "*" ], "Condition": { "Bool": { "iot:Connection.Thing.IsAttached": ["true"] } } } ] }

以下のポリシーでは、証明書が特定のモノのタイプを持つモノにアタッチされ、そのモノが値 attributeValue を持つ attributeName の属性を持つ場合、デバイスの公開を許可します。モノのポリシー変数の詳細については、[Thing policy variables] (モノのポリシー変数) を参照してください。

JSON
{ "Version":"2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Publish" ], "Resource": "arn:aws:iot:us-east-1:123456789012:topic/device/stats", "Condition": { "StringEquals": { "iot:Connection.Thing.Attributes[attributeName]": "attributeValue", "iot:Connection.Thing.ThingTypeName": "Thing_Type_Name" }, "Bool": { "iot:Connection.Thing.IsAttached": "true" } } } ] }

次のポリシーでは、デバイスはモノの属性で始まるトピックにパブリッシュすることができます。デバイス証明書がモノに関連付けられていない場合、この変数は解決されず、アクセス拒否エラーが発生します。モノのポリシー変数の詳細については、[Thing policy variables] (モノのポリシー変数) を参照してください。

JSON
{ "Version":"2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:Publish" ], "Resource": "arn:aws:iot:us-east-1:123456789012:topic/${iot:Connection.Thing.Attributes[attributeName]}/*" } ] }