我成功地部署了一个Cognito User Pool,并使用它对我在API网关中设置为API代理的方法进行了身份验证,现在我正在创建同一堆栈的Cloudformation模板。使用Cloudformation,我设置了API网关和使用我的用户池的Authorizer。工作正常。当我尝试部署一个使用Authorizer的方法时,它失败了,原因是:
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而不是引用Authorizer,也会发生同样的问题。
Cloudformation的Authorizer docs说Ref!
应该返回ID,所以我真的很困惑这是怎么回事。
对我来说似乎是个bug,但也许我遗漏了什么?
https://stackoverflow.com/questions/47619302
复制相似问题