【问题标题】:AWS API Gateway documentation. Mention of an API Key for all methodsAWS API 网关文档。提及所有方法的 API 密钥
【发布时间】:2023-02-10 18:28:35
【问题描述】:
我们在 AWS Api 网关中发布了一个 Rest-Api 到开发者门户。我想要完成的是,在 Developer portals API 文档中提到了每种方法都需要 Api Key。
我知道如果在 API 网关中我打开方法请求并将 x-api-key 添加到所需的 HTTP 请求标头。部署 API 开发人员门户后,会在方法参数中显示此必需的标头。
完成这项工作的正确方法是什么?有几十个端点,我不认为当整个系统依赖于 Api Key 时,这必须为方法一个一个地添加。
【问题讨论】:
标签:
amazon-web-services
swagger
aws-api-gateway
openapi
amazon-api-gateway
【解决方案1】:
我最终将 ApiKey 标头添加到每个方法中,只是为了确保它显示在开发人员门户文档中。这样我们的旧用户就会知道有新的标头可用于 API 网关。
我遍历每个方法并使用新的必需标头更新它们,如下所示:
aws apigateway update-method --rest-api-id foo --resource-id bar --http-method GET --patch-operations op="add",path="/requestParameters/method.request.header.x-api-key",value="true" --profile myProfile
如果有人有更好的主意,请告诉我。