UserPool¶
-
class
aws_cdk.aws_cognito.
UserPool
(scope, id, *, account_recovery=None, auto_verify=None, custom_attributes=None, email_settings=None, enable_sms_role=None, lambda_triggers=None, mfa=None, mfa_second_factor=None, password_policy=None, self_sign_up_enabled=None, sign_in_aliases=None, sign_in_case_sensitive=None, sms_role=None, sms_role_external_id=None, standard_attributes=None, user_invitation=None, user_pool_name=None, user_verification=None)¶ Bases:
aws_cdk.core.Resource
Define a Cognito User Pool.
- Parameters
scope (
Construct
) –id (
str
) –account_recovery (
Optional
[AccountRecovery
]) – How will a user be able to recover their account? Default: AccountRecovery.PHONE_WITHOUT_MFA_AND_EMAILauto_verify (
Optional
[AutoVerifiedAttrs
]) – Attributes which Cognito will look to verify automatically upon user sign up. EMAIL and PHONE are the only available options. Default: - IfsignInAlias
includes email and/or phone, they will be included inautoVerifiedAttributes
by default. If absent, no attributes will be auto-verified.custom_attributes (
Optional
[Mapping
[str
,ICustomAttribute
]]) – Define a set of custom attributes that can be configured for each user in the user pool. Default: - No custom attributes.email_settings (
Optional
[EmailSettings
]) – Email settings for a user pool. Default: - see defaults on each property of EmailSettings.enable_sms_role (
Optional
[bool
]) – Setting this would explicitly enable or disable SMS role creation. When left unspecified, CDK will determine based on other properties if a role is needed or not. Default: - CDK will determine based on other properties of the user pool if an SMS role should be created or not.lambda_triggers (
Optional
[UserPoolTriggers
]) – Lambda functions to use for supported Cognito triggers. Default: - No Lambda triggers.mfa (
Optional
[Mfa
]) – Configure whether users of this user pool can or are required use MFA to sign in. Default: Mfa.OFFmfa_second_factor (
Optional
[MfaSecondFactor
]) – Configure the MFA types that users can use in this user pool. Ignored ifmfa
is set toOFF
. Default: - { sms: true, oneTimePassword: false }, ifmfa
is set toOPTIONAL
orREQUIRED
. { sms: false, oneTimePassword: false }, otherwisepassword_policy (
Optional
[PasswordPolicy
]) – Password policy for this user pool. Default: - see defaults on each property of PasswordPolicy.self_sign_up_enabled (
Optional
[bool
]) – Whether self sign up should be enabled. This can be further configured via theselfSignUp
property. Default: falsesign_in_aliases (
Optional
[SignInAliases
]) – Methods in which a user registers or signs in to a user pool. 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 }
. Default: { username: true }sign_in_case_sensitive (
Optional
[bool
]) – 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 eitherMyUsername
ormyusername
. Default: truesms_role (
Optional
[IRole
]) – The IAM role that Cognito will assume while sending SMS messages. Default: - a new IAM role is createdsms_role_external_id (
Optional
[str
]) – The ‘ExternalId’ that Cognito service must using when assuming thesmsRole
, if the role is restricted with an ‘sts:ExternalId’ conditional. 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 ifsmsRole
is not specified. Default: - No external id will be configuredstandard_attributes (
Optional
[StandardAttributes
]) – The set of attributes that are required for every user in the user pool. Read more on attributes here - https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-attributes.html Default: - All standard attributes are optional and mutable.user_invitation (
Optional
[UserInvitationConfig
]) – Configuration around admins signing up users into a user pool. Default: - see defaults in UserInvitationConfiguser_pool_name (
Optional
[str
]) – Name of the user pool. Default: - automatically generated name by CloudFormation at deploy timeuser_verification (
Optional
[UserVerificationConfig
]) – Configuration around users signing themselves up to the user pool. Enable or disable self sign-up via theselfSignUpEnabled
property. Default: - see defaults in UserVerificationConfig
Methods
-
add_client
(id, *, access_token_validity=None, auth_flows=None, disable_o_auth=None, generate_secret=None, id_token_validity=None, o_auth=None, prevent_user_existence_errors=None, read_attributes=None, refresh_token_validity=None, supported_identity_providers=None, user_pool_client_name=None, write_attributes=None)¶ Add a new app client to this user pool.
- Parameters
id (
str
) –access_token_validity (
Optional
[Duration
]) – Validity of the access token. Values between 5 minutes and 1 day are valid. The duration can not be longer than the refresh token validity. Default: Duration.minutes(60)auth_flows (
Optional
[AuthFlow
]) – The set of OAuth authentication flows to enable on the client. Default: - all auth flows disableddisable_o_auth (
Optional
[bool
]) – Turns off all OAuth interactions for this client. Default: falsegenerate_secret (
Optional
[bool
]) – Whether to generate a client secret. Default: falseid_token_validity (
Optional
[Duration
]) – Validity of the ID token. Values between 5 minutes and 1 day are valid. The duration can not be longer than the refresh token validity. Default: Duration.minutes(60)o_auth (
Optional
[OAuthSettings
]) – OAuth settings for this to client to interact with the app. An error is thrown when this is specified anddisableOAuth
is set. Default: - see defaults inOAuthSettings
. meaningless ifdisableOAuth
is set.prevent_user_existence_errors (
Optional
[bool
]) – Whether Cognito returns a UserNotFoundException exception when the user does not exist in the user pool (false), or whether it returns another type of error that doesn’t reveal the user’s absence. Default: true for new stacksread_attributes (
Optional
[ClientAttributes
]) – The set of attributes this client will be able to read. Default: - all standard and custom attributesrefresh_token_validity (
Optional
[Duration
]) – Validity of the refresh token. Values between 60 minutes and 10 years are valid. Default: Duration.days(30)supported_identity_providers (
Optional
[List
[UserPoolClientIdentityProvider
]]) – The list of identity providers that users should be able to use to sign in using this client. Default: - supports all identity providers that are registered with the user pool. If the user pool and/or identity providers are imported, either specify this option explicitly or ensure that the identity providers are registered with the user pool using theUserPool.registerIdentityProvider()
API.user_pool_client_name (
Optional
[str
]) – Name of the application client. Default: - cloudformation generated namewrite_attributes (
Optional
[ClientAttributes
]) – The set of attributes this client will be able to write. Default: - all standard and custom attributes
- Return type
-
add_domain
(id, *, cognito_domain=None, custom_domain=None)¶ Associate a domain to this user pool.
- Parameters
id (
str
) –cognito_domain (
Optional
[CognitoDomainOptions
]) – Associate a cognito prefix domain with your user pool EithercustomDomain
orcognitoDomain
must be specified. Default: - not set ifcustomDomain
is specified, otherwise, throws an error.custom_domain (
Optional
[CustomDomainOptions
]) – Associate a custom domain with your user pool EithercustomDomain
orcognitoDomain
must be specified. Default: - not set ifcognitoDomain
is specified, otherwise, throws an error.
- Return type
-
add_resource_server
(id, *, identifier, scopes=None, user_pool_resource_server_name=None)¶ Add a new resource server to this user pool.
- Parameters
id (
str
) –identifier (
str
) – A unique resource server identifier for the resource server.scopes (
Optional
[List
[ResourceServerScope
]]) – Oauth scopes. Default: - No scopes will be addeduser_pool_resource_server_name (
Optional
[str
]) – A friendly name for the resource server. Default: - same asidentifier
- Return type
-
add_trigger
(operation, fn)¶ Add a lambda trigger to a user pool operation.
- Parameters
operation (
UserPoolOperation
) –fn (
IFunction
) –
- See
- Return type
None
-
register_identity_provider
(provider)¶ Register an identity provider with this user pool.
- Parameters
provider (
IUserPoolIdentityProvider
) –- Return type
None
-
to_string
()¶ Returns a string representation of this construct.
- Return type
str
Attributes
-
env
¶ The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
- Return type
-
identity_providers
¶ Get all identity providers registered with this user pool.
- Return type
-
node
¶ The construct tree node associated with this construct.
- Return type
-
user_pool_arn
¶ The ARN of the user pool.
- Return type
str
-
user_pool_id
¶ The physical ID of this user pool resource.
- Return type
str
-
user_pool_provider_name
¶ User pool provider name.
- Attribute
true
- Return type
str
-
user_pool_provider_url
¶ User pool provider URL.
- Attribute
true
- Return type
str
Static Methods
-
classmethod
from_user_pool_arn
(scope, id, user_pool_arn)¶ Import an existing user pool based on its ARN.
- Parameters
scope (
Construct
) –id (
str
) –user_pool_arn (
str
) –
- Return type
-
classmethod
from_user_pool_id
(scope, id, user_pool_id)¶ Import an existing user pool based on its id.
- Parameters
scope (
Construct
) –id (
str
) –user_pool_id (
str
) –
- Return type
-
classmethod
is_construct
(x)¶ Return whether the given object is a Construct.
- Parameters
x (
Any
) –- Return type
bool