

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

# 以 IAM 政策測試 VPC 設定
<a name="test-vpc-with-policies"></a>

您可以部署限制存取權的 IAM 政策，以進一步測試使用 Amazon EC2 或 WorkSpaces 設定的 VPC。

下列政策會拒絕存取 Amazon S3，除非它使用您指定的 VPC。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Deny",
            "Action": "S3:*",
            "Resource": "*",
            "Condition": {
                "StringNotEqualsIfExists": {
                    "aws:SourceVpc": "vpc-12345678"
                },
                "Bool": {
                    "aws:ViaAwsService": "false"
                }
            }
        }
    ]
}
```

------

下列政策限制使用 AWS 管理主控台 登入端點的私有存取政策登入 AWS 帳戶 IDs。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": "*",
            "Action": "*",
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "aws:PrincipalAccount": [
                        "AWSAccountID"
                    ]
                }
            }
        }
    ]
}
```

------

如果您連線的身分不屬於您的帳戶，則會顯示以下錯誤頁面。

![\[指出您未使用 AWS 管理主控台 私有存取許可訊息的錯誤頁面。\]](http://docs.aws.amazon.com/zh_tw/awsconsolehelpdocs/latest/gsg/images/console-private-access-denied.png)
