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,所以我真的很困惑这里发生了什么。
对我来说似乎是一个错误,但也许我错过了什么?
归档时间: |
|
查看次数: |
1770 次 |
最近记录: |