【问题标题】:Cognito User Pool trying to send SMS when it's configured for email sendingCognito 用户池在配置为发送电子邮件时尝试发送 SMS
【发布时间】:2019-11-03 12:42:08
【问题描述】:

我正在使用无服务器框架,以便使用以下 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。任何提示为什么会发生这种情况?

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

    • 只是想添加到这个答案,因为我遇到了与 boto3 sdk 类似的问题。由于DesiredDeliveryMedium 的默认设置默认为SMS,如果您使用CognitoIdentityProvider Boto3 客户端调用admin_create_user(),您必须将DesiredDeliveryMedium 作为参数传递,并将值设置为email,以便邀请电子邮件将发送而不是 SMS。
    猜你喜欢
    • 2019-08-29
    • 1970-01-01
    • 2019-12-04
    • 2022-10-08
    • 2020-10-09
    • 1970-01-01
    • 2020-06-24
    • 2017-10-30
    • 1970-01-01
    相关资源
    最近更新 更多