4

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?

1 Answers1

6

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.

  • 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. – Alex Mar 25 '21 at 19:16