Amazon web services 配置API网关方法以从阶段继承限制设置
我正在使用AWS CLIAmazon web services 配置API网关方法以从阶段继承限制设置,amazon-web-services,aws-sdk,aws-api-gateway,aws-cli,throttling,Amazon Web Services,Aws Sdk,Aws Api Gateway,Aws Cli,Throttling,我正在使用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 如何使用CLI(或AWS SD
update 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
如何使用CLI(或AWS SDK)获取方法以再次从后台继承设置?这里的问题是删除调用的路径。您正在使用“/~1cats~1{pawId}/GET/throttling/rateLimit” API网关支持删除所有方法设置,而不仅仅是特定的方法设置。我从我的删除呼叫中删除了“/限制/速率限制”,它成功了 我运行了以下命令,它可以正常工作
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 api网关更新阶段--rest api id--阶段名称--修补程序操作op=replace,path='/hw/GET/throttling/rateLimit',value=20
{
“部署ID”:“,
“stageName”:“,
“cacheClusterEnabled”:false,
“cacheClusterStatus”:“不可用”,
“方法设置”:{
“硬件/获取”:{
“metricsEnabled”:false,
“DataTraceeEnabled”:false,
“节流负荷限制”:5000,
“ThrottlingLatelimit”:20.0,
“咯咯笑”:错,
“cacheTtlInSeconds”:300,
“cacheDataEncrypted”:false,
“requireAuthorizationForCacheControl”:true,
“unauthorizedCacheControlHeaderStrategy”:“使用响应头成功”
}
},
“可追溯”:假,
“createdDate”:“2020-04-24T13:50:18-07:00”,
“LastUpdateDate”:“2020-04-27T01:21:45-07:00”
}
aws apigateway更新阶段--rest api id--阶段名称--修补程序操作op=remove,path=/hw/GET,value=“”
{
“部署ID”:“,
“stageName”:“,
“cacheClusterEnabled”:false,
“cacheClusterStatus”:“不可用”,
“方法设置”:{},
“可追溯”:假,
“createdDate”:“2020-04-24T13:50:18-07:00”,
“LastUpdateDate”:“2020-04-27T01:36:12-07:00”
}
我通过检查API网关控制台发出的网络调用找到了此解决方案。谢谢,这很有用,但是我必须只更改节流设置,而不是其他任何设置,因为该方法可能有其他设置覆盖默认设置。有没有办法告诉它从舞台上获取节流设置?我认为目前不可能。当提到方法级覆盖时,所有设置都从覆盖中读取,而不是默认为阶段。
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
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"
}