

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

# モノのポリシーの例
<a name="thing-policy-examples"></a>

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

****  

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

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

****  

```
{
  "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]](thing-policy-variables.md) (モノのポリシー変数) を参照してください。

****  

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