需要同时检查的几个方面:
确保使用计划指向的API在相应的区域内
确保API网关中的API名称与输入的名称匹配
确保在使用计划和API网关中使用了相同的密钥
下面是一些可能出现上述问题情况的代码示例:
从使用计划中获取Api的名称:
aws apigateway get-usage-plan --usage-plan-id
从API网关中获取Api的名称:
aws apigateway get-rest-apis
检查是否密钥是否一致(以下是CLI命令示例):
aws apigateway get-api-keys
aws apigateway get-usage-plan-keys --usage-plan-id
在API网关中创建API时需要--endpoint-type REGIONAL
参数,并且对于某些特定区域需要使用特定的选项,例如在华东区需要添加地域选项--region cn-north-1
。
在API网关中创建API时参考以下命令示例:
aws apigateway create-rest-api --name --endpoint-type REGIONAL --region <区域>