配置API网关方法以继承阶段的节流设置



我正在使用AWS CLIupdate-stage命令为API网关方法配置特定的节流设置,该方法工作正常:

aws apigateway update-stage --rest-api-id <the-id> --stage-name <the-stage-name>
--patch-operations op=replace,path='/~1cats~1{pawId}/GET/throttling/rateLimit',value=10

然而,当我试图删除我刚刚配置的设置,并从后台继承节流设置时,默认情况下,我会得到一个错误:

aws apigateway update-stage --rest-api-id <the-id> --stage-name <the-stage-name>
--patch-operations op=remove,path='/~1cats~1{pawId}/GET/throttling/rateLimit'
An error occurred (BadRequestException) when calling the UpdateStage operation:
Cannot remove method setting ~1cats~1{pawId}/GET/throttling/rateLimit because there
is no method setting for this method

我如何使用CLI(或AWS SDK(再次获得从后台继承设置的方法?

这里的问题是remove调用的路径。您正在使用"/~1cats~1{pawId}/GET/节流/速率限制"。

API网关支持删除所有方法设置,而不仅仅是一个特定的方法设置。我从我的remove调用中删除了"/straining/rateLimit",它起了作用。

我运行了以下命令,它工作

aws apigateway update-stage --rest-api-id <> --stage-name <> --patch-operations op=replace,path='/hw/GET/throttling/rateLimit',value=20
{
"deploymentId": "<>",
"stageName": "<>",
"cacheClusterEnabled": false,
"cacheClusterStatus": "NOT_AVAILABLE",
"methodSettings": {
"hw/GET": {
"metricsEnabled": false,
"dataTraceEnabled": false,
"throttlingBurstLimit": 5000,
"throttlingRateLimit": 20.0,
"cachingEnabled": false,
"cacheTtlInSeconds": 300,
"cacheDataEncrypted": false,
"requireAuthorizationForCacheControl": true,
"unauthorizedCacheControlHeaderStrategy": "SUCCEED_WITH_RESPONSE_HEADER"
}
},
"tracingEnabled": false,
"createdDate": "2020-04-24T13:50:18-07:00",
"lastUpdatedDate": "2020-04-27T01:21:45-07:00"
}
aws apigateway update-stage --rest-api-id <> --stage-name <> --patch-operations op=remove,path=/hw/GET,value=""
{
"deploymentId": "<>",
"stageName": "<>",
"cacheClusterEnabled": false,
"cacheClusterStatus": "NOT_AVAILABLE",
"methodSettings": {},
"tracingEnabled": false,
"createdDate": "2020-04-24T13:50:18-07:00",
"lastUpdatedDate": "2020-04-27T01:36:12-07:00"
}

我通过检查API网关控制台进行的网络调用找到了这个解决方案。

最新更新