配置为发送电子邮件时,Cognito用户池尝试发送SMS

时间:2019-06-20 16:26:11

标签: amazon-web-services amazon-cognito serverless-framework aws-serverless serverless-architecture

我正在使用无服务器框架,以便使用以下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 个答案:

答案 0 :(得分:0)

发现了问题,实际上与用户池无关。我有一个创建默认用户的资源,它没有设置DesiredDeliveryMedium属性。所述属性默认为SMS,将其设置为EMAIL即可解决。