Gaurav Thantry
Gaurav Thantry

Reputation: 803

AWS Cognito: Unable to set some properties for create-user-pool using aws cli

I am trying to create a user-pool on cognito using the AWS CLI from a json file. The pool is being created, but I am not able to set some of its properties.

Note: Some of the snapshots attached below are taken from the AWS Docs for creating user pool.

  1. I am not able to find a way to set the Email as a verification attribute.

    Snapshot:

    enter image description here

  2. The email message and subject is not being customized, eventhough I am specifying them in my json file. This brings me to another question (Point 3).

    enter image description here

  3. The AWS documentation for creating a user pool through CLI mentions three properties.

snapshot:

enter image description here

Below is the JSON object that I formed to create the pool

{
    "PoolName": "xxx-userpool-local",
    "Policies": {
        "PasswordPolicy": {
            "MinimumLength": 8,
            "RequireUppercase": true,
            "RequireLowercase": true,
            "RequireNumbers": true,
            "RequireSymbols": true,
            "TemporaryPasswordValidityDays": 7
        }
    },
    "UsernameAttributes": [
        "email"
    ],
    "EmailVerificationMessage": "Please click the link below to verify your account. {####}",
    "EmailVerificationSubject": "Your account is ready",
    "VerificationMessageTemplate": {
        "EmailMessage": "Please click the link below to verify your account. {####}",
        "EmailSubject": "Your account is ready",
        "EmailMessageByLink": "Please click the link below to verify your account. {####}",
        "EmailSubjectByLink": "Your account is ready",
        "DefaultEmailOption": "CONFIRM_WITH_LINK"
    },
    "AdminCreateUserConfig": {
        "AllowAdminCreateUserOnly": false
    },
    "UsernameConfiguration": {
        "CaseSensitive": true
    },
    "AccountRecoverySetting": {
        "RecoveryMechanisms": [
            {
                "Priority": 1,
                "Name": "verified_email"
            }
        ]
    }
}

Upvotes: 1

Views: 276

Answers (1)

jellycsc
jellycsc

Reputation: 12259

  1. This option in the console maps to AutoVerifiedAttributes in CLI. In order to set the Email as a verification attribute, add the following code snippet to your JSON input:
"AutoVerifiedAttributes": [
 "email"
]
  1. It maps to AdminCreateUserConfig.InviteMessageTemplate in the CLI.
"AdminCreateUserConfig": {
  "AllowAdminCreateUserOnly": false,
  "InviteMessageTemplate": {
    "EmailMessage": "Your username is {username} and temporary password is {####}. ",
    "EmailSubject": "Your temporary password"
  }
}
  1. You can use the following config to select the verification link as an option instead of the verification code.
"VerificationMessageTemplate": {
  "EmailMessageByLink": "Please click the link below to verify your email address. {##Verify Email##} ",
  "EmailSubjectByLink": "Your verification link",
  "DefaultEmailOption": "CONFIRM_WITH_LINK"
}

Upvotes: 2

Related Questions