

# 限制用户查看特定的金丝雀
<a name="CloudWatch_Synthetics_Canaries_Restricted"></a>

您可以限制用户查看金丝雀相关信息，使他们只能看到您指定金丝雀的信息。为此，请将 IAM 策略与类似以下内容的 ` Condition` 声明配合使用，并将此策略附加到用户或 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` 数组中最多列出五个项目。

您也可以创建策略，在允许的金丝雀名称中使用 \$1** 作为通配符，如以下示例所示：

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

****  

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

------

使用所附的这些策略之一登录的任何用户都不能使用 CloudWatch 控制台查看任何金丝雀信息。他们只能使用 [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 命令，查看策略授权的金丝雀信息。