Getting AttributeError: module 'aws_cdk.aws_cognito' has no attribute 'UserPoolResourceServer' Error
Getting AttributeError: module 'aws_cdk.aws_cognito' has no attribute 'UserPoolResourceServer' Error
我正在尝试使用 python 代码创建 "CfnUserPoolResourceServer" 认知。根据 https://docs.aws.amazon.com/cdk/api/latest/python/aws_cdk.aws_cognito/CfnUserPoolResourceServer.html 我正在尝试设置 "scopes" 参数。
根据 https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cognito-userpoolresourceserver.html#cfn-cognito-userpoolresourceserver-scopes 文档,范围的类型是 "List of "ResourceServerScopeType”。所以我正在尝试初始化 ResourceServerScopeType 对象,如下所示 -
_rs = _cognito.UserPoolResourceServer()
_rs1 = _rs.ResourceServerScopeType
_rs1.Scopes.ScopeName = "access_db_data"
_rs1.Scopes.ScopeDescription = "access data from table"
但我遇到了以下错误 -
AttributeError: module 'aws_cdk.aws_cognito' has no attribute 'UserPoolResourceServer'
我无法理解如何为 CfnUserPoolResourceServer 设置 "scopes" 参数。请帮帮我。
您需要直接使用CfnUserPoolResourceServer
。
from aws_cdk import (
aws_cognito as _cognito,
core,
)
class CognitoStack(core.Stack):
def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
super().__init__(scope, id, **kwargs)
_rs = _cognito.CfnUserPoolResourceServer(
self, 'rs',
identifier='identifier_here',
name='name_here',
user_pool_id='user_pool_id_here',
scopes=[
{
'scopeName': 'access_db_data',
'scopeDescription': 'access data from table'
}
]
)
我正在尝试使用 python 代码创建 "CfnUserPoolResourceServer" 认知。根据 https://docs.aws.amazon.com/cdk/api/latest/python/aws_cdk.aws_cognito/CfnUserPoolResourceServer.html 我正在尝试设置 "scopes" 参数。 根据 https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cognito-userpoolresourceserver.html#cfn-cognito-userpoolresourceserver-scopes 文档,范围的类型是 "List of "ResourceServerScopeType”。所以我正在尝试初始化 ResourceServerScopeType 对象,如下所示 -
_rs = _cognito.UserPoolResourceServer()
_rs1 = _rs.ResourceServerScopeType
_rs1.Scopes.ScopeName = "access_db_data"
_rs1.Scopes.ScopeDescription = "access data from table"
但我遇到了以下错误 -
AttributeError: module 'aws_cdk.aws_cognito' has no attribute 'UserPoolResourceServer'
我无法理解如何为 CfnUserPoolResourceServer 设置 "scopes" 参数。请帮帮我。
您需要直接使用CfnUserPoolResourceServer
。
from aws_cdk import (
aws_cognito as _cognito,
core,
)
class CognitoStack(core.Stack):
def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
super().__init__(scope, id, **kwargs)
_rs = _cognito.CfnUserPoolResourceServer(
self, 'rs',
identifier='identifier_here',
name='name_here',
user_pool_id='user_pool_id_here',
scopes=[
{
'scopeName': 'access_db_data',
'scopeDescription': 'access data from table'
}
]
)