module.exports.createUserPool = function()

in source/user-manager/cognito-user.js [153:298]


module.exports.createUserPool = function (tenantId) {
    var promise = new Promise(function(resolve, reject) {
        // init the service provider and email message content
        var cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider({
            apiVersion: '2016-04-18',
            region: configuration.aws_region
        });

        // var SnsArn = configuration.role.sns;
        //Invite Message:
        var inviteMessage = '<img src="https://d0.awsstatic.com/partner-network/logo_apn.png" alt="AWSPartner"> <br><br>Welcome to the SaaS on AWS Bootcamp. <br><br>Login to the Multi-Tenant Identity Reference Architecture. <br><br>Username: {username} <br><br>Password: {####}';
        var emailSubject = 'AWS-SaaS-Bootcamp';
        // init JSON structure with pool settings
        var params = {
            PoolName: tenantId, /* required */
            AdminCreateUserConfig: {
                AllowAdminCreateUserOnly: true,
                InviteMessageTemplate: {
                    EmailMessage: inviteMessage,
                    EmailSubject: emailSubject
                    // SMSMessage: 'STRING_VALUE'
                },
                UnusedAccountValidityDays: 7
            },
            AliasAttributes: [
                'phone_number'
            ],
            AutoVerifiedAttributes: [
                'email'
                //, 'phone_number'
                /* more items */
            ],
            MfaConfiguration: 'OFF',
            Policies: {
                PasswordPolicy: {
                    MinimumLength: 8,
                    RequireLowercase: true,
                    RequireNumbers: true,
                    RequireSymbols: false,
                    RequireUppercase: true
                }
            },
            Schema: [
                {
                    AttributeDataType: 'String',
                    DeveloperOnlyAttribute: false,
                    Mutable: false,
                    Name: 'tenant_id',
                    NumberAttributeConstraints: {
                        MaxValue: '256',
                        MinValue: '1'
                    },
                    Required: false,
                    StringAttributeConstraints: {
                        MaxLength: '256',
                        MinLength: '1'
                    }
                },
                /* more items */
                {
                    AttributeDataType: 'String',
                    DeveloperOnlyAttribute: false,
                    Mutable: true,
                    Name: 'tier',
                    NumberAttributeConstraints: {
                        MaxValue: '256',
                        MinValue: '1'
                    },
                    Required: false,
                    StringAttributeConstraints: {
                        MaxLength: '256',
                        MinLength: '1'
                    }
                },
                {
                    Name: "email",
                    Required: true
                },
                {
                    AttributeDataType: 'String',
                    DeveloperOnlyAttribute: false,
                    Mutable: true,
                    Name: 'company_name',
                    NumberAttributeConstraints: {
                        MaxValue: '256',
                        MinValue: '1'
                    },
                    Required: false,
                    StringAttributeConstraints: {
                        MaxLength: '256',
                        MinLength: '1'
                    }
                },
                {
                    AttributeDataType: 'String',
                    DeveloperOnlyAttribute: false,
                    Mutable: true,
                    Name: 'role',
                    NumberAttributeConstraints: {
                        MaxValue: '256',
                        MinValue: '1'
                    },
                    Required: false,
                    StringAttributeConstraints: {
                        MaxLength: '256',
                        MinLength: '1'
                    }
                },
                {
                    AttributeDataType: 'String',
                    DeveloperOnlyAttribute: false,
                    Mutable: true,
                    Name: 'account_name',
                    NumberAttributeConstraints: {
                        MaxValue: '256',
                        MinValue: '1'
                    },
                    Required: false,
                    StringAttributeConstraints: {
                        MaxLength: '256',
                        MinLength: '1'
                    }
                }
            ],
            // SmsConfiguration: {
            //     SnsCallerArn: SnsArn, /* required */
            //     ExternalId: 'AWSSaaSBootcamp'
            // },
            UserPoolTags: {
                someKey: tenantId
                /* anotherKey: ... */
            }
        };

        // create the pool
        cognitoidentityserviceprovider.createUserPool(params, function (err, data) {
            if (err) {
                reject(err);
            } else {
                resolve(data);
            }
        });
    });

    return promise;
}