首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >无法在API Gateway Cloudformation中设置Cognito用户池AuthorizerId

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

Stack Overflow用户
提问于 2017-12-03 14:21:09
回答 0查看 1.9K关注 0票数 5

我成功地部署了一个Cognito User Pool,并使用它对我在API网关中设置为API代理的方法进行了身份验证,现在我正在创建同一堆栈的Cloudformation模板。使用Cloudformation,我设置了API网关和使用我的用户池的Authorizer。工作正常。当我尝试部署一个使用Authorizer的方法时,它失败了,原因是:

代码语言:javascript
运行
AI代码解释
复制
Invalid authorizer ID specified. Setting the authorization type to CUSTOM
or COGNITO_USER_POOLS requires a valid authorizer.

这是Cloudformation堆栈的相关部分:

代码语言:javascript
运行
AI代码解释
复制
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而不是引用Authorizer,也会发生同样的问题。

Cloudformation的Authorizer docsRef!应该返回ID,所以我真的很困惑这是怎么回事。

对我来说似乎是个bug,但也许我遗漏了什么?

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47619302

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档