

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

# 限制使用者檢視特定的 canary
<a name="CloudWatch_Synthetics_Canaries_Restricted"></a>

您可限制使用者檢視有關 canary 資訊的能力，讓他們只能查看您指定的 canary相關資訊。如要執行此作業，請使用具有類似下列內容之 ` Condition` 陳述式的 IAM 政策，並將此政策連接至使用者或 IAM 角色。

下列範例限制使用者僅可查看 ` name-of-allowed-canary-1` 和 `name-of-allowed-canary-2` 的相關資訊。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "synthetics:DescribeCanaries",
            "Resource": "*",
            "Condition": {
                "ForAnyValue:StringEquals": {
                    "synthetics:Names": [
                        "name-of-allowed-canary-1",
                        "name-of-allowed-canary-2"
                    ]
                }
            }
        }
    ]
}
```

------

CloudWatch Synthetics 支援 `synthetics:Names` 陣列中列出的最多五個項目。

您還可建立於允許的 canary 名稱中使用 \$1** 作為萬用字元的政策，如下列範例所示：

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "synthetics:DescribeCanaries",
            "Resource": "*",
            "Condition": {
                "ForAnyValue:StringLike": {
                    "synthetics:Names": [
                        "my-team-canary-*"
                    ]
                }
            }
        }
    ]
}
```

------

使用連結的其中一個政策登入的任何使用者皆不可使用 CloudWatch 主控台檢視任何 canary 的資訊。他們只能檢視政策所授權之 canary 的 canary 資訊，且只能透過使用 [DescribeCanaries](https://docs.aws.amazon.com/AmazonSynthetics/latest/APIReference/API_DescribeCanaries.html) API 或 [describe-canaries](https://docs.aws.amazon.com/cli/latest/reference/synthetics/describe-canaries.html) AWS CLI 命令。