CloudFormation中AWS::Cognito::UserPool属性验证失败求助
排查AWS CloudFormation Cognito UserPool属性验证失败问题
错误根源分析
你的模板存在3处类型不匹配问题,直接导致Property validation failure:
AllowAdminCreateUserOnly类型错误:该属性要求布尔值(true/false),你写成了字符串'True'UserPoolTags格式错误:Tags必须是键值对对象,而非单纯字符串- Schema中的布尔属性类型错误:
Mutable、Required、DeveloperOnlyAttribute这些属性都要求布尔值,你写成了字符串'true'/'false'
修正后的模板
Resources: ESRVCognitoUserPool: Type: "AWS::Cognito::UserPool" Properties: UserPoolName: !Sub '${AWS::StackName}-CognitoUserPool' AdminCreateUserConfig: AllowAdminCreateUserOnly: true # 改为布尔值,去掉引号 UserPoolTags: StackName: !Sub '${AWS::StackName}' # 改为键值对格式 Schema: - Name: 'country_code' AttributeDataType: 'String' Mutable: true # 去掉引号,用布尔值 Required: false DeveloperOnlyAttribute: false StringAttributeConstraints: MaxLength: '2048' MinLength: '1' - Name: "contact_id" AttributeDataType: String Mutable: true Required: false DeveloperOnlyAttribute: false StringAttributeConstraints: MaxLength: '2048' MinLength: '1' - Name: "language" AttributeDataType: String Mutable: true Required: false DeveloperOnlyAttribute: false StringAttributeConstraints: MaxLength: '256' MinLength: '1' - Name: "account_id" AttributeDataType: String Mutable: true Required: false DeveloperOnlyAttribute: false StringAttributeConstraints: MaxLength: '2048' MinLength: '1' - Name: "tracking_id" AttributeDataType: String Mutable: true Required: false DeveloperOnlyAttribute: false StringAttributeConstraints: MaxLength: '256' MinLength: '1' Outputs: StackName: Description: 'Stack name.' Value: !Sub '${AWS::StackName}' UserPoolInfo: Description: 'UserPool Information' Value: !Ref ESRVCognitoUserPool Export: Name: UserPool-ID
额外排查建议
如果修正后仍有错误,查看CloudFormation控制台的事件详情,里面会明确指出具体是哪个属性验证失败,针对性调整即可。
内容的提问来源于stack exchange,提问作者kofisis
相关产品推荐
相关产品推荐

