Cognito User Pool trying to send SMS when it's configured for email sending
S

2

5

I'm using the serverless framework in order to create a Cognito User Pool using the following CloudFormation configuration:

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}"

As you can see, the AutoVerifiedAttributes is set to email; so, Cognito should send the verification code through the email configured in SES. But I'm getting the following error in my CI/CD pipeline: User pool does not have SMS configuration to send messages. Any hints of why is this happening?

Samala answered 20/6, 2019 at 16:26 Comment(0)
S
7

Found the issue, it was actually not related to the user pool. I had a resource that created the default user, which had not set the DesiredDeliveryMedium property; said property defaults to SMS, setting it to EMAIL solved it.

Samala answered 3/7, 2019 at 19:34 Comment(1)
Just wanted to add to this answer since I came across a similar issue with the boto3 sdk. Since the default setting for DesiredDeliveryMedium defaults to SMS, if you are using CognitoIdentityProvider Boto3 client to call admin_create_user(), you must pass DesiredDeliveryMedium as an argument and set the value to email such that the invitation email will be sent instead of an SMS.Loaning
V
0

As of 2024-03-16, the argument is: DesiredDeliveryMediums=['EMAIL']

Vanhook answered 16/3 at 15:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.