如何使用CloudFormation添加UserPool的资源服务器?

问题描述 投票:5回答:3

使用CloudFormation,如何在AWS Cognito中为UserPool创建资源服务器?

在CloudFormation文档中,Cognito下只有5个项目,我看不到如何配置ResourceServer,这有可能吗?

谢谢。

amazon-web-services amazon-cloudformation amazon-cognito
3个回答
1
投票

现在可以直接在具有AWS::Cognito::UserPoolResourceServer资源类型的cloudformation上使用。您无需创建自定义资源即可创建资源服务器。现在,它由cloudformation支持。见https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cognito-userpoolresourceserver.html我试图将自定义资源更新为cloudformation,但是由于某种原因,资源服务器不可更新。因此,首先我必须删除一个变更集中的自定义资源,然后将其重新创建为AWS::Cognito::UserPoolResourceServer


1
投票

CloudFormation不支持资源服务器以及其他项。这是所有supported resources的列表。

作为CloudFormation的替代方法,您可以使用CLI or SDK to provision and manage a Resource Server。使用SDK,您可以在CloudFormation中创建一个Lambda-Backed Customer Resource。然后,您可以在CloudFormation中将资源服务器添加为自定义资源。


0
投票

您可以使用this通用自定义资源提供程序。

像这样使用(未经测试,但应该可以正常工作::

  ResourceServer:
    Type: 'Custom::CognitoResourceServer'
    Properties:
      ServiceToken: !Sub '${CustomResourceLambdaArn}'
      AgentService: cognito-idp
      AgentType: client
      AgentCreateMethod: create_resource_server
      AgentUpdateMethod: update_resource_server
      AgentDeleteMethod: delete_resource_server
      AgentResourceId: Name
      AgentCreateArgs:
        UserPoolId: !Sub '${UserPool}'
        Name: 'my-resource-server'
        Identifier: 'https://foo.bar'
        Scopes:
        - ScopeName: 'my-scope'
        - ScopeDescription: 'My scope.'
      AgentUpdateArgs:
        UserPoolId: !Sub '${UserPool}'
        Name: 'my-resource-server'
        Identifier: 'https://foo.bar'
        Scopes:
        - ScopeName: 'my-scope'
        - ScopeDescription: 'My scope.'
      AgentDeleteArgs:
        Identifier: 'https://foo.bar'

API reference

© www.soinside.com 2019 - 2024. All rights reserved.