【发布时间】:2018-08-03 16:24:12
【问题描述】:
我有一个使用 Swagger 定义的 API,它定义了以下 API Key 授权方:
securityDefinitions:
api_key:
type: apiKey
name: x-api-key
in: header
x-amazon-apigateway-authtype: "oauth2"
x-amazon-apigateway-authorizer:
type: token
authorizerUri: arn:aws:apigateway:eu-west-1:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-1:[accountid]:function:ApiKeyAuthorizerLambdaFunction/invocations
authorizerResultTtlInSeconds: 0
但是,当我将此 Swagger 定义传递到我的 CloudFormation 脚本并调用受此授权方保护的端点时,我得到一个 500。API 网关日志显示以下内容:
Incoming identity: ***key
Execution failed due to configuration error: Invalid permissions on Lambda function
Execution failed due to configuration error: Authorizer error
请注意,我 已授予 API 网关执行此 lambda 的权限:
LambdaPermissionAuthorizerApiGateway:
Type: AWS::Lambda::Permission
Properties:
FunctionName:
Fn::GetAtt:
- ApiKeyAuthorizerLambdaFunction
- Arn
Action: lambda:InvokeFunction
Principal: apigateway.amazonaws.com
事实上,当我将 Serverless 为授权端点生成的 CloudFormation 脚本(使用 Serverless 的表示法)与我自己使用 Swagger 的 CloudFormation 脚本进行比较时,我发现它们之间几乎没有区别,除了我的授权人是使用 Swagger 定义而不是直接作为 CF 资源。
任何人都可以对此有所了解吗?这是将 Swagger 与 CloudFormation 结合使用时的错误吗?
【问题讨论】:
-
能否请您发布使用授权方的端点之一的配置?
-
嗨,你能解决这个问题吗?我也面临同样的问题
-
很遗憾,我认为我们没有这样做,抱歉。
标签: swagger aws-api-gateway amazon-cloudformation