# UserPool

Define a Cognito User Pool.

Extends: Construct › Resource › UserPool
Implements: IResource, IUserPool, IEnvironmentAware, IUserPoolRef, IConstruct, IDependable

- CloudFormation: [`AWS::Cognito::UserPool`](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-resource-cognito-userpool.html)
- L1 type: [`CfnUserPool`](/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.CfnUserPool.html)
- Source: [`aws-cognito/lib/user-pool.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-cognito/lib/user-pool.ts#L1083)
- Type last changed: v2.235.0 · 15 Jan 2026

## Example

```ts
const pool = new cognito.UserPool(this, 'Pool');
pool.addClient('app-client', {
  oAuth: {
    flows: {
      authorizationCodeGrant: true,
    },
    scopes: [ cognito.OAuthScope.OPENID ],
    callbackUrls: [ 'https://my-app-domain.com/welcome' ],
    logoutUrls: [ 'https://my-app-domain.com/signin' ],
  },
});
```

## Initializer

```ts
new UserPool(scope: Construct, id: string, props?: UserPoolProps)
```

## Construct Props

- `accountRecovery`: [AccountRecovery](/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.AccountRecovery.html) — How will a user be able to recover their account?

  **Default:** AccountRecovery.PHONE_WITHOUT_MFA_AND_EMAIL

- `advancedSecurityMode`: [AdvancedSecurityMode](/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.AdvancedSecurityMode.html) — Advanced Security Mode is deprecated due to user pool feature plans. Use StandardThreatProtectionMode and CustomThreatProtectionMode to set Thread Protection level.

  **Default:** no value

- `autoVerify`: [AutoVerifiedAttrs](/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.AutoVerifiedAttrs.html) — Attributes which Cognito will look to verify automatically upon user sign up.

  **Default:** If `signInAlias` includes email and/or phone, they will be included in `autoVerifiedAttributes` by default. If absent, no attributes will be auto-verified.

  EMAIL and PHONE are the only available options.

- `customAttributes`: { [key: string]: [ICustomAttribute](/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.ICustomAttribute.html) } — Define a set of custom attributes that can be configured for each user in the user pool.

  **Default:** No custom attributes.

- `customSenderKmsKey`: [IKeyRef](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_kms.IKeyRef.html) — This key will be used to encrypt temporary passwords and authorization codes that Amazon Cognito generates.

  **Default:** no key ID configured

- `customThreatProtectionMode`: [CustomThreatProtectionMode](/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.CustomThreatProtectionMode.html) — The Type of Threat Protection Enabled for Custom Authentication.

  **Default:** no value

  This feature only functions if your FeaturePlan is set to FeaturePlan.PLUS

- `deletionProtection`: boolean = false — Indicates whether the user pool should have deletion protection enabled.

- `deviceTracking`: [DeviceTracking](/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.DeviceTracking.html) — Device tracking settings.

  **Default:** see defaults on each property of DeviceTracking.

- `email`: [UserPoolEmail](/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.UserPoolEmail.html) — Email settings for a user pool.

  **Default:** cognito will use the default email configuration

- `enableSmsRole`: boolean — Setting this would explicitly enable or disable SMS role creation.

  **Default:** CDK will determine based on other properties of the user pool if an SMS role should be created or not.

  When left unspecified, CDK will determine based on other properties if a role is needed or not.

- `featurePlan`: [FeaturePlan](/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.FeaturePlan.html) — The user pool feature plan, or tier.

  **Default:** FeaturePlan.ESSENTIALS for a newly created user pool; FeaturePlan.LITE otherwise

  This parameter determines the eligibility of the user pool for features like managed login, access-token customization, and threat protection.

- `keepOriginal`: [KeepOriginalAttrs](/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.KeepOriginalAttrs.html) — Attributes which Cognito will look to handle changes to the value of your users' email address and phone number attributes.

  **Default:** Nothing is kept.

  EMAIL and PHONE are the only available options.

- `lambdaTriggers`: [UserPoolTriggers](/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.UserPoolTriggers.html) — Lambda functions to use for supported Cognito triggers.

  **Default:** No Lambda triggers.

- `mfa`: [Mfa](/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.Mfa.html) = Mfa.OFF — Configure whether users of this user pool can or are required use MFA to sign in.

- `mfaMessage`: string — The SMS message template sent during MFA verification.

  **Default:** 'Your authentication code is {####}.'

  Use '{####}' in the template where Cognito should insert the verification code.

- `mfaSecondFactor`: [MfaSecondFactor](/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.MfaSecondFactor.html) — Configure the MFA types that users can use in this user pool.

  **Default:** { sms: true, otp: false, email: false }, if `mfa` is set to `OPTIONAL` or `REQUIRED`. { sms: false, otp: false, email:false }, otherwise

  Ignored if `mfa` is set to `OFF`.

- `passkeyRelyingPartyId`: string — The authentication domain that passkey providers must use as a relying party (RP) in their configuration.

  **Default:** No authentication domain

  Under the following conditions, the passkey relying party ID must be the fully-qualified domain name of your custom domain:
  - The user pool is configured for passkey authentication.
  - The user pool has a custom domain, whether or not it also has a prefix domain.
  - Your application performs authentication with managed login or the classic hosted UI.

- `passkeyUserVerification`: [PasskeyUserVerification](/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.PasskeyUserVerification.html) — Your user-pool treatment for MFA with a passkey.

  **Default:** Cognito default setting is PasskeyUserVerification.PREFERRED

  You can override other MFA options and require passkey MFA, or you can set it as preferred.
  When passkey MFA is preferred, the hosted UI encourages users to register a passkey at sign-in.

- `passwordPolicy`: [PasswordPolicy](/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.PasswordPolicy.html) — Password policy for this user pool.

  **Default:** see defaults on each property of PasswordPolicy.

- `removalPolicy`: [RemovalPolicy](/cdk/api/v2/docs/aws-cdk-lib.RemovalPolicy.html) = RemovalPolicy.RETAIN — Policy to apply when the user pool is removed from the stack.

- `selfSignUpEnabled`: boolean = false — Whether self sign-up should be enabled.

  To configure self sign-up configuration use the `userVerification` property.

- `signInAliases`: [SignInAliases](/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.SignInAliases.html) — Methods in which a user registers or signs in to a user pool.

  **Default:** { username: true }

  Allows either username with aliases OR sign in with email, phone, or both.

  Read the sections on usernames and aliases to learn more -
  https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-attributes.html

  To match with 'Option 1' in the above link, with a verified email, this property should be set to
  `{ username: true, email: true }`. To match with 'Option 2' in the above link with both a verified email and phone
  number, this property should be set to `{ email: true, phone: true }`.

- `signInCaseSensitive`: boolean = true — Whether sign-in aliases should be evaluated with case sensitivity.

  For example, when this option is set to false, users will be able to sign in using either `MyUsername` or `myusername`.

- `signInPolicy`: [SignInPolicy](/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.SignInPolicy.html) — Sign-in policy for this user pool.

  **Default:** see defaults on each property of SignInPolicy.

- `smsRole`: [IRoleRef](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_iam.IRoleRef.html) — The IAM role that Cognito will assume while sending SMS messages.

  **Default:** a new IAM role is created.

- `smsRoleExternalId`: string — The 'ExternalId' that Cognito service must be using when assuming the `smsRole`, if the role is restricted with an 'sts:ExternalId' conditional.

  **Default:** No external id will be configured.

  Learn more about ExternalId here - https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-user_externalid.html

  This property will be ignored if `smsRole` is not specified.

- `snsRegion`: string — The region to integrate with SNS to send SMS messages.

  **Default:** The same region as the user pool, with a few exceptions - https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-sms-settings.html#user-pool-sms-settings-first-time

  This property will do nothing if SMS configuration is not configured.

- `standardAttributes`: [StandardAttributes](/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.StandardAttributes.html) — The set of attributes that are required for every user in the user pool.

  **Default:** All standard attributes are optional and mutable.

  Read more on attributes here - https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-attributes.html

- `standardThreatProtectionMode`: [StandardThreatProtectionMode](/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.StandardThreatProtectionMode.html) — The Type of Threat Protection Enabled for Standard Authentication.

  **Default:** StandardThreatProtectionMode.NO_ENFORCEMENT

  This feature only functions if your FeaturePlan is set to FeaturePlan.PLUS

- `userInvitation`: [UserInvitationConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.UserInvitationConfig.html) — Configuration around admins signing up users into a user pool.

  **Default:** see defaults in UserInvitationConfig.

- `userPoolName`: string — Name of the user pool.

  **Default:** automatically generated name by CloudFormation at deploy time.

- `userVerification`: [UserVerificationConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.UserVerificationConfig.html) — Configuration around users signing themselves up to the user pool.

  **Default:** see defaults in UserVerificationConfig.

  Enable or disable self sign-up via the `selfSignUpEnabled` property.

## Properties

- `env`: [ResourceEnvironment](/cdk/api/v2/docs/aws-cdk-lib.interfaces.ResourceEnvironment.html) — The environment this resource belongs to.

  For resources that are created and managed in a Stack (those created by
  creating new class instances like `new Role()`, `new Bucket()`, etc.), this
  is always the same as the environment of the stack they belong to.

  For referenced resources (those obtained from referencing methods like
  `Role.fromRoleArn()`, `Bucket.fromBucketName()`, etc.), they might be
  different than the stack they were imported into.

- `identityProviders`: [IUserPoolIdentityProvider](/cdk/api/v2/docs/aws-cdk-lib.aws_cognito.IUserPoolIdentityProvider.html)[] — Get all identity providers registered with this user pool.

- `node`: [Node](/cdk/api/v2/docs/constructs.Node.html) — The tree node.

- `PROPERTY_INJECTION_ID`: string (static) — Uniquely identifies this class.

- `stack`: [Stack](/cdk/api/v2/docs/aws-cdk-lib.Stack.html) — The stack in which this resource is defined.

- `userPoolArn`: string — The ARN of the user pool.

- `userPoolId`: string — The physical ID of this user pool resource.

- `userPoolProviderName`: string — User pool provider name.

- `userPoolProviderUrl`: string — User pool provider URL.

- `userPoolRef`: [UserPoolReference](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_cognito.UserPoolReference.html) — A reference to a UserPool resource.

## Methods

- `addClient(id: string, options?: UserPoolClientOptions): UserPoolClient` — Add a new app client to this user pool.

- `addDomain(id: string, options: UserPoolDomainOptions): UserPoolDomain` — Associate a domain to this user pool.

- `addGroup(id: string, options: UserPoolGroupOptions): UserPoolGroup` — Add a new group to this user pool.

- `addResourceServer(id: string, options: UserPoolResourceServerOptions): UserPoolResourceServer` — Add a new resource server to this user pool.

- `addTrigger(operation: UserPoolOperation, fn: IFunction, lambdaVersion?: LambdaVersion): void` — Add a lambda trigger to a user pool operation.

- `applyCrossStackReferenceStrength(strength: ReferenceStrength): void` — Override the cross-stack reference strength for this resource.

  When set, any cross-stack reference to this resource will use the specified
  mechanism instead of the global default determined by the
  `@aws-cdk/core:defaultCrossStackReferences` context key. This is useful for
  selectively weakening specific references to avoid the "deadly embrace" problem
  without changing the app-wide default.

  **Parameters**

  - `strength` — - The reference strength to use for this resource.

- `applyRemovalPolicy(policy: RemovalPolicy): void` — Apply the given removal policy to this resource.

  The Removal Policy controls what happens to this resource when it stops
  being managed by CloudFormation, either because you've removed it from the
  CDK application or because you've made a change that requires the resource
  to be replaced.

  The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS
  account for data recovery and cleanup later (`RemovalPolicy.RETAIN`).

- `fromUserPoolArn(scope: Construct, id: string, userPoolArn: string): IUserPool` (static) — Import an existing user pool based on its ARN.

- `fromUserPoolId(scope: Construct, id: string, userPoolId: string): IUserPool` (static) — Import an existing user pool based on its id.

- `grant(grantee: IGrantable, ...actions: string[]): Grant` — [disable-awslint:no-grants].

- `isConstruct(x: any): boolean` (static) — Checks if `x` is a construct.

  Use this method instead of `instanceof` to properly detect `Construct`
  instances, even when the construct library is symlinked.

  Explanation: in JavaScript, multiple copies of the `constructs` library on
  disk are seen as independent, completely different libraries. As a
  consequence, the class `Construct` in each copy of the `constructs` library
  is seen as a different class, and an instance of one class will not test as
  `instanceof` the other class. `npm install` will not create installations
  like this, but users may manually symlink construct libraries together or
  use a monorepo tool: in those cases, multiple copies of the `constructs`
  library can be accidentally installed, and `instanceof` will behave
  unpredictably. It is safest to avoid using `instanceof`, and using
  this type-testing method instead.

  **Parameters**

  - `x` — Any object.

  **Returns:** true if `x` is an object created from a class which extends `Construct`.

- `isOwnedResource(construct: IConstruct): boolean` (static) — Returns true if the construct was created by CDK, and false otherwise.

- `isResource(construct: IConstruct): boolean` (static) — Check whether the given construct is a Resource.

- `registerIdentityProvider(provider: IUserPoolIdentityProviderRef): void` — Register an identity provider with this user pool.

- `toString(): string` — Returns a string representation of this construct.

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.
  Use multiple `with()` calls if subsequent mixins should apply to added
  constructs.
