【发布时间】:2021-11-22 11:59:51
【问题描述】:
使用 REST API (AWS API Gateway v1),我们可以在请求中使用 X-API-Key 标头并维护 API 密钥来控制对给定端点的访问。
在 AWS 中,如果我转到 API Gateway 并选择 REST API (v1),然后在 Resources 下我看到:API Key Required 在 API Keys 下我可以找到我的密钥。
使用serverless可以这样配置:
provider:
apiKeys:
- my-api-key
functions:
hello:
handler: handler.hello
events:
- http:
path: /hello
method: get
private: true
但如果我切换到httpApi,我会得到:
Configuration warning at 'functions.hello.events[0].httpApi': unrecognized property 'private'
此外,在 API Gateway 中,在 HTTP API (v2) 下,任何地方都没有 API 密钥。
当我查看文档时,在 REST API 下有一个关于 API Keys 的重要部分: https://www.serverless.com/framework/docs/providers/aws/events/apigateway 但 API Gateway HTTP API 与 API 密钥无关: https://www.serverless.com/framework/docs/providers/aws/events/http-api
HTTP API (API Gateway v2) 中是否有 REST API (API Gateway v1) API 密钥等效?基本上,我希望能够像在 REST API 中一样将X-API-Key 与 HTTP API 一起使用。
【问题讨论】:
标签: amazon-web-services rest aws-api-gateway serverless aws-http-api