

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

# x-amazon-apigateway-policy
<a name="openapi-extensions-policy"></a>

指定 REST API 的資源政策。如需進一步了解以資源為基礎的政策，請參閱[使用 API Gateway 資源政策來控制對 REST API 的存取](apigateway-resource-policies.md)。如需資源策略範例，請參閱 [API Gateway 資源政策範例](apigateway-resource-policies-examples.md)。

## `x-amazon-apigateway-policy` 範例
<a name="openapi-extensions-policy-example"></a>

下列範例會指定 REST API 的資源政策。資源策略會拒絕 (封鎖) 來自指定來源 IP 位址區塊的 API 傳入流量。匯入時`arn:aws:execute-api:region:account-id:api-id/*`， 會使用目前的區域、 AWS 您的帳戶 ID 和目前的 REST API ID `"execute-api:/*"`轉換為 。

```
"x-amazon-apigateway-policy": {
    "Version": "2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": "*",
            "Action": "execute-api:Invoke",
            "Resource": [
                "execute-api:/*"
            ]
        },
        {
            "Effect": "Deny",
            "Principal": "*",
            "Action": "execute-api:Invoke",
            "Resource": [
               "execute-api:/*"
            ],
            "Condition" : {
                "IpAddress": {
                    "aws:SourceIp": "192.0.2.0/24"
                }
            }
        }
    ]
}
```