我喜欢通过基于Java的AWS-CDK版本0.24.1创建一个认知用户池。在cdk deploy
期间,我收到错误InvalidParameterException。
服务:AWSCognitoIdentityProvider;
状态码::400;
错误代码: InvalidParameterException:Cognito无效的AttributeDataType输入,请考虑使用提供的AttributeDataType枚举
CfnUserPool userPool = new CfnUserPool(this, "cognito",
CfnUserPoolProps.builder()
.withAdminCreateUserConfig(
AdminCreateUserConfigProperty.builder()
.withAllowAdminCreateUserOnly(false)
.build())
.withPolicies(
PoliciesProperty.builder()
.withPasswordPolicy(
PasswordPolicyProperty.builder()
.withMinimumLength(6)
.withRequireLowercase(false)
.withRequireNumbers(false)
.withRequireSymbols(false)
.withRequireUppercase(false)
.build()
)
.build()
)
.withAutoVerifiedAttributes(Arrays.asList("email"))
.withSchema(Arrays.asList("email"))
.build());
简单字符串列表.withAutoVerifiedAttributes(Arrays.asList("email"))
或 .withSchema(Arrays.asList("email"))
可能是错误的。但不幸的是,只有方法签名中声明的对象列表,而没有具体的类型:public CfnUserPoolProps.Builder withAutoVerifiedAttributes(@Nullable List value)
。
是否有一个示例片段使用基于Java的aws-cdk创建类似的用户池。
答案 0 :(得分:0)
CfnUserPool.SchemaAttributeProperty.builder()
的用法解决了该问题。我认为SchemaAttributeProperty
是方法withSchema(@Nullable List< Object > value)
CfnUserPool userPool = new CfnUserPool(this, "cognito",
CfnUserPoolProps.builder()
.withAdminCreateUserConfig(
AdminCreateUserConfigProperty.builder()
.withAllowAdminCreateUserOnly(false)
.build())
.withPolicies(
PoliciesProperty.builder()
.withPasswordPolicy(
PasswordPolicyProperty.builder()
.withMinimumLength(6)
.withRequireLowercase(false)
.withRequireNumbers(false)
.withRequireSymbols(false)
.withRequireUppercase(false)
.build()
)
.build()
)
.withAutoVerifiedAttributes(Arrays.asList("email"))
.withSchema(Arrays.asList(
CfnUserPool.SchemaAttributeProperty.builder()
.withAttributeDataType("String")
.withName("email")
.withRequired(true)
.build()))
.build());