UserPool class
Provides a Cognito User Pool resource.
Example Usage
Basic configuration
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const pool = new aws.cognito.UserPool("pool", {name: "mypool"});
import pulumi
import pulumi_aws as aws
pool = aws.cognito.UserPool("pool", name="mypool")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var pool = new Aws.Cognito.UserPool("pool", new()
{
Name = "mypool",
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/cognito"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := cognito.NewUserPool(ctx, "pool", &cognito.UserPoolArgs{
Name: pulumi.String("mypool"),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
resource "aws_cognito_userpool" "pool" {
name = "mypool"
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.cognito.UserPool;
import com.pulumi.aws.cognito.UserPoolArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var pool = new UserPool("pool", UserPoolArgs.builder()
.name("mypool")
.build());
}
}
resources:
pool:
type: aws:cognito:UserPool
properties:
name: mypool
Enabling SMS and Software Token Multi-Factor Authentication
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.cognito.UserPool("example", {
smsConfiguration: {
externalId: "example",
snsCallerArn: exampleAwsIamRole.arn,
snsRegion: "us-east-1",
},
softwareTokenMfaConfiguration: {
enabled: true,
},
mfaConfiguration: "ON",
smsAuthenticationMessage: "Your code is {####}",
});
import pulumi
import pulumi_aws as aws
example = aws.cognito.UserPool("example",
sms_configuration={
"external_id": "example",
"sns_caller_arn": example_aws_iam_role["arn"],
"sns_region": "us-east-1",
},
software_token_mfa_configuration={
"enabled": True,
},
mfa_configuration="ON",
sms_authentication_message="Your code is {####}")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.Cognito.UserPool("example", new()
{
SmsConfiguration = new Aws.Cognito.Inputs.UserPoolSmsConfigurationArgs
{
ExternalId = "example",
SnsCallerArn = exampleAwsIamRole.Arn,
SnsRegion = "us-east-1",
},
SoftwareTokenMfaConfiguration = new Aws.Cognito.Inputs.UserPoolSoftwareTokenMfaConfigurationArgs
{
Enabled = true,
},
MfaConfiguration = "ON",
SmsAuthenticationMessage = "Your code is {####}",
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/cognito"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := cognito.NewUserPool(ctx, "example", &cognito.UserPoolArgs{
SmsConfiguration: &cognito.UserPoolSmsConfigurationArgs{
ExternalId: pulumi.String("example"),
SnsCallerArn: pulumi.Any(exampleAwsIamRole.Arn),
SnsRegion: pulumi.String("us-east-1"),
},
SoftwareTokenMfaConfiguration: &cognito.UserPoolSoftwareTokenMfaConfigurationArgs{
Enabled: pulumi.Bool(true),
},
MfaConfiguration: pulumi.String("ON"),
SmsAuthenticationMessage: pulumi.String("Your code is {####}"),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
resource "aws_cognito_userpool" "example" {
sms_configuration = {
external_id = "example"
sns_caller_arn = exampleAwsIamRole.arn
sns_region = "us-east-1"
}
software_token_mfa_configuration = {
enabled = true
}
mfa_configuration = "ON"
sms_authentication_message = "Your code is {####}"
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.cognito.UserPool;
import com.pulumi.aws.cognito.UserPoolArgs;
import com.pulumi.aws.cognito.inputs.UserPoolSmsConfigurationArgs;
import com.pulumi.aws.cognito.inputs.UserPoolSoftwareTokenMfaConfigurationArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new UserPool("example", UserPoolArgs.builder()
.smsConfiguration(UserPoolSmsConfigurationArgs.builder()
.externalId("example")
.snsCallerArn(exampleAwsIamRole.arn())
.snsRegion("us-east-1")
.build())
.softwareTokenMfaConfiguration(UserPoolSoftwareTokenMfaConfigurationArgs.builder()
.enabled(true)
.build())
.mfaConfiguration("ON")
.smsAuthenticationMessage("Your code is {####}")
.build());
}
}
resources:
example:
type: aws:cognito:UserPool
properties:
smsConfiguration:
externalId: example
snsCallerArn: ${exampleAwsIamRole.arn}
snsRegion: us-east-1
softwareTokenMfaConfiguration:
enabled: true
mfaConfiguration: ON
smsAuthenticationMessage: Your code is {####}
Using Account Recovery Setting
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const test = new aws.cognito.UserPool("test", {
accountRecoverySetting: {
recoveryMechanisms: [
{
name: "verified_email",
priority: 1,
},
{
name: "verified_phone_number",
priority: 2,
},
],
},
name: "mypool",
});
import pulumi
import pulumi_aws as aws
test = aws.cognito.UserPool("test",
account_recovery_setting={
"recovery_mechanisms": [
{
"name": "verified_email",
"priority": 1,
},
{
"name": "verified_phone_number",
"priority": 2,
},
],
},
name="mypool")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var test = new Aws.Cognito.UserPool("test", new()
{
AccountRecoverySetting = new Aws.Cognito.Inputs.UserPoolAccountRecoverySettingArgs
{
RecoveryMechanisms = new[]
{
new Aws.Cognito.Inputs.UserPoolAccountRecoverySettingRecoveryMechanismArgs
{
Name = "verified_email",
Priority = 1,
},
new Aws.Cognito.Inputs.UserPoolAccountRecoverySettingRecoveryMechanismArgs
{
Name = "verified_phone_number",
Priority = 2,
},
},
},
Name = "mypool",
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/cognito"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := cognito.NewUserPool(ctx, "test", &cognito.UserPoolArgs{
AccountRecoverySetting: &cognito.UserPoolAccountRecoverySettingArgs{
RecoveryMechanisms: cognito.UserPoolAccountRecoverySettingRecoveryMechanismArray{
&cognito.UserPoolAccountRecoverySettingRecoveryMechanismArgs{
Name: pulumi.String("verified_email"),
Priority: pulumi.Int(1),
},
&cognito.UserPoolAccountRecoverySettingRecoveryMechanismArgs{
Name: pulumi.String("verified_phone_number"),
Priority: pulumi.Int(2),
},
},
},
Name: pulumi.String("mypool"),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
resource "aws_cognito_userpool" "test" {
account_recovery_setting = {
recovery_mechanisms = [{
"name" = "verified_email"
"priority" = 1
}, {
"name" = "verified_phone_number"
"priority" = 2
}]
}
name = "mypool"
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.cognito.UserPool;
import com.pulumi.aws.cognito.UserPoolArgs;
import com.pulumi.aws.cognito.inputs.UserPoolAccountRecoverySettingArgs;
import com.pulumi.aws.cognito.inputs.UserPoolAccountRecoverySettingRecoveryMechanismArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var test = new UserPool("test", UserPoolArgs.builder()
.accountRecoverySetting(UserPoolAccountRecoverySettingArgs.builder()
.recoveryMechanisms(
UserPoolAccountRecoverySettingRecoveryMechanismArgs.builder()
.name("verified_email")
.priority(1)
.build(),
UserPoolAccountRecoverySettingRecoveryMechanismArgs.builder()
.name("verified_phone_number")
.priority(2)
.build())
.build())
.name("mypool")
.build());
}
}
resources:
test:
type: aws:cognito:UserPool
properties:
accountRecoverySetting:
recoveryMechanisms:
- name: verified_email
priority: 1
- name: verified_phone_number
priority: 2
name: mypool
Import
Using pulumi import, import Cognito User Pools using the id. For example:
$ pulumi import aws:cognito/userPool:UserPool pool us-west-2_abc123
Constructors
- UserPool(String name, {UserPoolArgs? args, CustomResourceOptions? options})
-
Creates a new UserPool.
nameThe Pulumi resource name.argsArguments used to configure this UserPool. The set of arguments for UserPool.optionsResource options controlling this resource's behavior. - UserPool.reference(String urn)
- Creates a typed reference to an existing UserPool resource.
Properties
-
accountRecoverySetting
↔ Output<
UserPoolAccountRecoverySetting?> -
Configuration block to define which verified available method a user can use to recover their forgotten password. Detailed below.
latefinal
-
adminCreateUserConfig
↔ Output<
UserPoolAdminCreateUserConfig> -
Configuration block for creating a new user profile. Detailed below.
latefinal
-
aliasAttributes
↔ Output<
List< String> ?> -
Attributes supported as an alias for this user pool. Valid values:
phoneNumber,email, orpreferredUsername. Conflicts withusernameAttributes.latefinal -
arn
↔ Output<
String> -
ARN of the user pool.
latefinal
-
autoVerifiedAttributes
↔ Output<
List< String> ?> -
Attributes to be auto-verified. Valid values:
email,phoneNumber.latefinal -
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
creationDate
↔ Output<
String> -
Date the user pool was created.
latefinal
-
customDomain
↔ Output<
String> -
A custom domain name that you provide to Amazon Cognito. This parameter applies only if you use a custom domain to host the sign-up and sign-in pages for your application. For example:
auth.example.com.latefinal -
deletionProtection
↔ Output<
String?> -
When active, DeletionProtection prevents accidental deletion of your user pool. Before you can delete a user pool that you have protected against deletion, you must deactivate this feature. Valid values are
ACTIVEandINACTIVE, Default value isINACTIVE.latefinal -
deviceConfiguration
↔ Output<
UserPoolDeviceConfiguration?> -
Configuration block for the user pool's device tracking. Detailed below.
latefinal
-
domain
↔ Output<
String> -
Holds the domain prefix if the user pool has a domain associated with it.
latefinal
-
emailConfiguration
↔ Output<
UserPoolEmailConfiguration?> -
Configuration block for configuring email. Detailed below.
latefinal
-
emailMfaConfiguration
↔ Output<
UserPoolEmailMfaConfiguration?> -
Configuration block for configuring email Multi-Factor Authentication (MFA); requires at least 2
accountRecoverySettingentries; requires anemailConfigurationconfiguration block. Effective only whenmfaConfigurationisONorOPTIONAL. Detailed below.latefinal -
emailVerificationMessage
↔ Output<
String> -
String representing the email verification message. Conflicts with
verificationMessageTemplateconfiguration blockemailMessageargument.latefinal -
emailVerificationSubject
↔ Output<
String> -
String representing the email verification subject. Conflicts with
verificationMessageTemplateconfiguration blockemailSubjectargument.latefinal -
endpoint
↔ Output<
String> -
Endpoint name of the user pool. Example format:
cognito-idp.REGION.amazonaws.com/xxxx_yyyyylatefinal -
estimatedNumberOfUsers
↔ Output<
int> -
A number estimating the size of the user pool.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
lambdaConfig
↔ Output<
UserPoolLambdaConfig?> -
Configuration block for the AWS Lambda triggers associated with the user pool. Detailed below.
latefinal
-
lastModifiedDate
↔ Output<
String> -
Date the user pool was last modified.
latefinal
-
mfaConfiguration
↔ Output<
String?> -
Multi-Factor Authentication (MFA) configuration for the User Pool. Defaults of
OFF. Valid values areOFF(MFA Tokens are not required),ON(MFA is required for all users to sign in; requires at least one ofemailMfaConfiguration,smsConfigurationorsoftwareTokenMfaConfigurationto be configured), orOPTIONAL(MFA Will be required only for individual users who have MFA Enabled; requires at least one ofemailMfaConfiguration,smsConfigurationorsoftwareTokenMfaConfigurationto be configured).latefinal -
name
↔ Output<
String> -
Name of the user pool.
latefinal
-
passwordPolicy
↔ Output<
UserPoolPasswordPolicy> -
Configuration block for information about the user pool password policy. Detailed below.
latefinal
-
region
↔ Output<
String> -
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
schemas
↔ Output<
List< UserPoolSchema> ?> -
Configuration block for the schema attributes of a user pool. Detailed below. Schema attributes from the standard attribute set only need to be specified if they are different from the default configuration. Attributes can be added, but not modified or removed. Maximum of 50 attributes.
latefinal
-
signInPolicy
↔ Output<
UserPoolSignInPolicy> -
Configuration block for information about the user pool sign in policy. Detailed below.
latefinal
-
smsAuthenticationMessage
↔ Output<
String?> -
String representing the SMS authentication message. The Message must contain the
{####}placeholder, which will be replaced with the code.latefinal -
smsConfiguration
↔ Output<
UserPoolSmsConfiguration> -
Configuration block for Short Message Service (SMS) settings. Detailed below. These settings apply to SMS user verification and SMS Multi-Factor Authentication (MFA). SMS MFA is activated only when
mfaConfigurationis set toONorOPTIONALalong with this block. Due to Cognito API restrictions, the SMS configuration cannot be removed without recreating the Cognito User Pool. For user data safety, this resource will ignore the removal of this configuration by disabling drift detection. To force resource recreation after this configuration has been applied, see thetaintcommand.latefinal -
smsVerificationMessage
↔ Output<
String> -
String representing the SMS verification message. Conflicts with
verificationMessageTemplateconfiguration blocksmsMessageargument.latefinal -
softwareTokenMfaConfiguration
↔ Output<
UserPoolSoftwareTokenMfaConfiguration?> -
Configuration block for software token Mult-Factor Authentication (MFA) settings. Effective only when
mfaConfigurationisONorOPTIONAL. Detailed below.latefinal -
Map of tags to assign to the User Pool. If configured with a provider
defaultTagsconfiguration block present, tags with matching keys will overwrite those defined at the provider-level.latefinal -
A map of tags assigned to the resource, including those inherited from the provider
defaultTagsconfiguration block.latefinal -
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
-
userAttributeUpdateSettings
↔ Output<
UserPoolUserAttributeUpdateSettings?> -
Configuration block for user attribute update settings. Detailed below.
latefinal
-
usernameAttributes
↔ Output<
List< String> ?> -
Whether email addresses or phone numbers can be specified as usernames when a user signs up. Conflicts with
aliasAttributes.latefinal -
usernameConfiguration
↔ Output<
UserPoolUsernameConfiguration> -
Configuration block for username configuration. Detailed below.
latefinal
-
userPoolAddOns
↔ Output<
UserPoolUserPoolAddOns?> -
Configuration block for user pool add-ons to enable user pool advanced security mode features. Detailed below.
latefinal
-
userPoolTier
↔ Output<
String> -
The user pool feature plan, or tier. Valid values:
LITE,ESSENTIALS,PLUS.latefinal -
verificationMessageTemplate
↔ Output<
UserPoolVerificationMessageTemplate> -
Configuration block for verification message templates. Detailed below.
latefinal
-
webAuthnConfiguration
↔ Output<
UserPoolWebAuthnConfiguration?> -
Configuration block for web authn configuration. Detailed below.
latefinal
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited