【发布时间】:2018-05-17 02:07:28
【问题描述】:
我成功部署了 Cognito 用户池,并使用它对我设置为代理到 API 网关中的 API 的方法进行身份验证,现在我正在创建同一堆栈的 Cloudformation 模板。使用 Cloudformation,我设置了我的 API 网关和使用我的用户池的授权者。工作正常。当我尝试部署使用授权者的方法时,它失败了:
Invalid authorizer ID specified. Setting the authorization type to CUSTOM
or COGNITO_USER_POOLS requires a valid authorizer.
这是 Cloudformation 堆栈的相关部分:
TestMethod:
Type: AWS::ApiGateway::Method
Properties:
RestApiId: !Ref RestApi
ResourceId: !Ref TestResource
HttpMethod: POST
AuthorizationType: COGNITO_USER_POOLS
AuthorizerId: !Ref ApiAuthorizer
Integration:
Type: HTTP_PROXY
IntegrationHttpMethod: POST
Uri: https://api.example.com/test
ApiAuthorizer:
Type: "AWS::ApiGateway::Authorizer"
Properties:
AuthorizerResultTtlInSeconds: 300
IdentitySource: method.request.header.Authorization
Name: CognitoDefaultUserPoolAuthorizer
ProviderARNs:
- !ImportValue DefaultUserPool::Arn
RestApiId: !Ref RestApi
Type: "COGNITO_USER_POOLS"
Authorizer 部署良好,我可以在 Cloudformation 中看到它的 ID,并且该方法在没有添加授权的情况下部署良好。如果我直接声明 ID 而不是引用授权人,也会出现同样的问题。
Cloudformation 的 Authorizer docs 说 Ref! 应该返回 ID,所以我真的很困惑这里发生了什么。
对我来说似乎是一个错误,但也许我错过了什么?
【问题讨论】:
标签: amazon-web-services aws-api-gateway amazon-cloudformation amazon-cognito aws-cognito