【问题标题】:Cognito User Pool AuthorizerId cannot be set in API Gateway Cloudformation无法在 API Gateway Cloudformation 中设置 Cognito 用户池 AuthorizerId
【发布时间】: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 docsRef! 应该返回 ID,所以我真的很困惑这里发生了什么。

对我来说似乎是一个错误,但也许我错过了什么?

【问题讨论】:

    标签: amazon-web-services aws-api-gateway amazon-cloudformation amazon-cognito aws-cognito


    【解决方案1】:

    AWS 现已修复此问题。它按照我最初发布的示例工作。

    【讨论】:

    • 你能确认这仍然有效吗?我得到了与您在原始帖子中描述的完全相同的不良行为。
    猜你喜欢
    • 2019-04-01
    • 2019-03-14
    • 2017-11-14
    • 2018-03-02
    • 2018-08-13
    • 2020-03-29
    • 2020-07-22
    • 2018-02-11
    • 2018-02-28
    相关资源
    最近更新 更多