You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 13:03:20