Cognito 用户池在配置为发送电子邮件时尝试发送短信

Cognito 用户池在配置为发送电子邮件时尝试发送短信

我正在使用无服务器框架来使用以下 CloudFormation 配置创建 Cognito 用户池:

Resources:
  CognitoUserPool:
    Type: AWS::Cognito::UserPool
    Properties:
      # Generate a name based on the stage
      UserPoolName: ${opt:stage}-user-pool
      # Set email as an alias
      UsernameAttributes:
        - email
      AutoVerifiedAttributes:
        - email
      MfaConfiguration: OFF
      EmailVerificationMessage: 'message here'
      EmailVerificationSubject: 'subject here'
      Policies:
        PasswordPolicy:
          MinimumLength: 6
          RequireLowercase: true
          RequireNumbers: false
          RequireSymbols: true
          RequireUppercase: true
      Schema:
        - AttributeDataType: String
          DeveloperOnlyAttribute: false
          Mutable: true
          Name: address
          Required: true
        - AttributeDataType: String
          DeveloperOnlyAttribute: false
          Mutable: true
          Name: email
          Required: true
        - AttributeDataType: String
          DeveloperOnlyAttribute: false
          Mutable: true
          Name: family_name
          Required: true
        - AttributeDataType: String
          DeveloperOnlyAttribute: false
          Mutable: true
          Name: gender
          Required: true
        - AttributeDataType: String
          DeveloperOnlyAttribute: false
          Mutable: true
          Name: name
          Required: true
        - AttributeDataType: String
          DeveloperOnlyAttribute: false
          Mutable: true
          Name: phone_number
          Required: true
        - AttributeDataType: String
          DeveloperOnlyAttribute: false
          Mutable: true
          Name: website
          Required: true
        - AttributeDataType: String
          DeveloperOnlyAttribute: false
          Mutable: true
          Name: role
          Required: false
      EmailConfiguration:
        EmailSendingAccount: COGNITO_DEFAULT
        # The email is taken from command line arguments, the region and account id through pseudo parameters
        SourceArn: "arn:aws:ses:#{AWS::Region}:#{AWS::AccountId}:identity/${env:SES_EMAIL}"

如您所见,AutoVerifiedAttributes设置为电子邮件;因此,Cognito 应该通过 SES 中配置的电子邮件发送验证码。但我在 CI/CD 管道中收到以下错误:User pool does not have SMS configuration to send messages。有什么提示说明为什么会发生这种情况?

答案1

发现问题了,其实和用户池无关,我有一个创建默认用户的资源,但是没有设置属性DesiredDeliveryMedium,说属性默认为SMS,设置成 就EMAIL解决了。

相关内容