2

My setup:

flask - awsLambda - zappa - api gateway

I do have a simple app running via above mentioned services. In my zappa_settings.json I have 'api_key_required' set to true.

Is it possible to set it up the way, that I will be using api key for every resource endpoint, but one (swagger documentation).

If, yes, where actually do I have to set it up. I don't have any api key setup in my flask app, so I assume it has to be done somewhere in aws.console - but I cannot find it.

EDIT: Just to add to correct answer (below). If you use flasgger it is not sufficient to add just one public endpoint pointing to /apidocs. To make documentation work without api key I had to open these enpoints:

  1. /apidocs and /apidocs/{proxy+}
  2. /apispec_1.json - may be different in your case
  3. /flasgger_static and /flasgger_static/{proxy+}
4

1 回答 1

3

是的,这可以通过在 AWS 控制台中进行一些配置来实现。

在您的 API Gateway 设置中,您可能拥有使用 Zappa 部署创建的默认资源://{proxy+}.

默认资源

您现在可以手动创建与您的文档端点对应的新资源(例如/docs)。

点击“Actions”->“Create Resource”你可以创建新资源:

创建新资源

创建资源后,点击“Actions”->“Create Method”并选择“ANY”。在对话框中将方法和资源指向您的 Lambda 函数。

默认情况下,新资源不需要 API 密钥。

不需要 api 密钥

注意:您可能需要在更改生效之前重新部署网关。“操作”->“部署 API”。

于 2018-01-21T01:02:37.093 回答