无法在 API Gateway Cloudformation 中设置 Cognito 用户池 AuthorizerId

Mil*_*les 5 amazon-web-services aws-cloudformation amazon-cognito aws-api-gateway aws-cognito

我成功部署了一个 Cognito 用户池,并使用它来验证我设置为代理到 API 网关中的 API 的方法,现在我正在创建相同堆栈的 Cloudformation 模板。使用 Cloudformation,我设置了我的 API 网关和使用我的用户池的授权方。工作正常。当我尝试部署使用授权器的方法时,它没有说:

Invalid authorizer ID specified. Setting the authorization type to CUSTOM
or COGNITO_USER_POOLS requires a valid authorizer.
Run Code Online (Sandbox Code Playgroud)

这是 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"
Run Code Online (Sandbox Code Playgroud)

Authorizer 部署得很好,我可以在 Cloudformation 中看到它的 ID,并且该方法在没有添加授权的情况下部署得很好。如果我直接声明 ID 而不是引用授权方,也会发生同样的问题。

Cloudformation的Authorizer 文档说 aRef!应该返回 ID,所以我真的很困惑这里发生了什么。

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

Mil*_*les 2

AWS 现在已经修复了这个问题。它按照我原来发布的示例工作。

  • 您能确认这仍然有效吗?我遇到了与您在原始帖子中描述的完全相同的不良行为。 (2认同)