Skip to main content

Component: cognito

This component is responsible for provisioning and managing AWS Cognito resources.

This component can provision the following resources:


Stack Level: Global

Here's an example snippet for how to use this component:

workspace_enabled: true
enabled: true
# The full name of the User Pool will be: <namespace>-<environment>-<stage>-<name>
name: cognito
- name: "email"
attribute_data_type: "String"
developer_only_attribute: false
mutable: false
required: true


terraform>= 1.0.0
aws>= 4.8.0


aws>= 4.8.0






additional_tag_mapAdditional key-value pairs to add to each map in tags_as_list_of_maps. Not added to tags or id.
This is for some rare cases where resources want additional configuration of tags
and therefore take a list of maps with tag key, value, and additional configuration.
admin_create_user_configThe configuration for AdminCreateUser requestsmap(any){}no
admin_create_user_config_allow_admin_create_user_onlySet to true if only the administrator is allowed to create user profiles. Set to false if users can sign themselves up via an appbooltrueno
admin_create_user_config_email_messageThe message template for email messages. Must contain {username} and {####} placeholders, for username and temporary password, respectivelystring"{username}, your temporary password is {####}"no
admin_create_user_config_email_subjectThe subject line for email messagesstring"Your verification code"no
admin_create_user_config_sms_messageThe message template for SMS messages. Must contain {username} and {####} placeholders, for username and temporary password, respectivelystring"Your username is {username} and temporary password is {####}"no
alias_attributesAttributes supported as an alias for this user pool. Possible values: phone_number, email, or preferred_username. Conflicts with username_attributeslist(string)nullno
attributesID element. Additional attributes (e.g. workers or cluster) to add to id,
in the order they appear in the list. New attributes are appended to the
end of the list. The elements of the list are joined by the delimiter
and treated as a single ID element.
auto_verified_attributesThe attributes to be auto-verified. Possible values: email, phone_numberlist(string)[]no
client_access_token_validityTime limit, between 5 minutes and 1 day, after which the access token is no longer valid and cannot be used. This value will be overridden if you have entered a value in token_validity_units.number60no
client_allowed_oauth_flowsList of allowed OAuth flows (code, implicit, client_credentials)list(string)[]no
client_allowed_oauth_flows_user_pool_clientWhether the client is allowed to follow the OAuth protocol when interacting with Cognito user poolsbooltrueno
client_allowed_oauth_scopesList of allowed OAuth scopes (phone, email, openid, profile, and aws.cognito.signin.user.admin)list(string)[]no
client_callback_urlsList of allowed callback URLs for the identity providerslist(string)[]no
client_default_redirect_uriThe default redirect URI. Must be in the list of callback URLsstring""no
client_explicit_auth_flowsList of authentication flows (ADMIN_NO_SRP_AUTH, CUSTOM_AUTH_FLOW_ONLY, USER_PASSWORD_AUTH)list(string)[]no
client_generate_secretShould an application secret be generatedbooltrueno
client_id_token_validityTime limit, between 5 minutes and 1 day, after which the ID token is no longer valid and cannot be used. Must be between 5 minutes and 1 day. Cannot be greater than refresh token expiration. This value will be overridden if you have entered a value in token_validity_units.number60no
client_logout_urlsList of allowed logout URLs for the identity providerslist(string)[]no
client_nameThe name of the application clientstringnullno
client_prevent_user_existence_errorsChoose which errors and responses are returned by Cognito APIs during authentication, account confirmation, and password recovery when the user does not exist in the user pool. When set to ENABLED and the user does not exist, authentication returns an error indicating either the username or password was incorrect, and account confirmation and password recovery return a response indicating a code was sent to a simulated destination. When set to LEGACY, those APIs will return a UserNotFoundException exception if the user does not exist in the user pool.stringnullno
client_read_attributesList of user pool attributes the application client can read fromlist(string)[]no
client_refresh_token_validityThe time limit in days refresh tokens are valid for. Must be between 60 minutes and 3650 days. This value will be overridden if you have entered a value in token_validity_unitsnumber30no
client_supported_identity_providersList of provider names for the identity providers that are supported on this clientlist(string)[]no
client_token_validity_unitsConfiguration block for units in which the validity times are represented in. Valid values for the following arguments are: seconds, minutes, hours or days.any
"access_token": "minutes",
"id_token": "minutes",
"refresh_token": "days"
client_write_attributesList of user pool attributes the application client can write tolist(string)[]no
clientsUser Pool clients configurationany[]no
contextSingle object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables as null to use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional_tag_map, which are merged.
"additional_tag_map": {},
"attributes": [],
"delimiter": null,
"descriptor_formats": {},
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"labels_as_tags": [
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {},
"tenant": null
deletion_protection(Optional) 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 ACTIVE and INACTIVE, Default value is INACTIVE.string"INACTIVE"no
delimiterDelimiter to be used between ID elements.
Defaults to - (hyphen). Set to "" to use no delimiter at all.
descriptor_formatsDescribe additional descriptors to be output in the descriptors output map.
Map of maps. Keys are names of descriptors. Values are maps of the form
{<br/> format = string<br/> labels = list(string)<br/>}
(Type is any so the map values can later be enhanced to provide additional options.)
format is a Terraform format string to be passed to the format() function.
labels is a list of labels, in order, to pass to format() function.
Label values will be normalized before being passed to format() so they will be
identical to how they appear in id.
Default is {} (descriptors output will be empty).
device_configurationThe configuration for the user pool's device trackingmap(any){}no
device_configuration_challenge_required_on_new_deviceIndicates whether a challenge is required on a new device. Only applicable to a new deviceboolfalseno
device_configuration_device_only_remembered_on_user_promptIf true, a device is only remembered on user promptboolfalseno
domainCognito User Pool domainstringnullno
domain_certificate_arnThe ARN of an ISSUED ACM certificate in us-east-1 for a custom domainstringnullno
email_configurationEmail configurationmap(any){}no
email_configuration_email_sending_accountInstruct Cognito to either use its built-in functionality or Amazon SES to send out emails. Allowed values: COGNITO_DEFAULT or DEVELOPERstring"COGNITO_DEFAULT"no
email_configuration_from_email_addressSender’s email address or sender’s display name with their email address (e.g. [email protected], John Smith <[email protected]> or "John Smith Ph.D." <[email protected]>). Escaped double quotes are required around display names that contain certain characters as specified in RFC 5322stringnullno
email_configuration_reply_to_email_addressThe REPLY-TO email addressstring""no
email_configuration_source_arnThe ARN of the email configuration sourcestring""no
email_verification_messageA string representing the email verification messagestringnullno
email_verification_subjectA string representing the email verification subjectstringnullno
enabledSet to false to prevent the module from creating any resourcesboolnullno
environmentID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT'stringnullno
id_length_limitLimit id to this many characters (minimum 6).
Set to 0 for unlimited length.
Set to null for keep the existing setting, which defaults to 0.
Does not affect id_full.
identity_providersCognito Identity Providers configurationlist(any)[]no
label_key_caseControls the letter case of the tags keys (label names) for tags generated by this module.
Does not affect keys of tags passed in via the tags input.
Possible values: lower, title, upper.
Default value: title.
label_orderThe order in which the labels (ID elements) appear in the id.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present.
label_value_caseControls the letter case of ID elements (labels) as included in id,
set as tag values, and output by this module individually.
Does not affect values of tags passed in via the tags input.
Possible values: lower, title, upper and none (no transformation).
Set this to title and set delimiter to "" to yield Pascal Case IDs.
Default value: lower.
labels_as_tagsSet of labels (ID elements) to include as tags in the tags output.
Default is to include all labels.
Tags with empty values will not be included in the tags output.
Set to [] to suppress all generated tags.
The value of the name tag, if included, will be the id, not the name.
Unlike other null-label inputs, the initial setting of labels_as_tags cannot be
changed in later chained modules. Attempts to change it will be silently ignored.
lambda_configConfiguration for the AWS Lambda triggers associated with the User Poolanynullno
lambda_config_create_auth_challengeThe ARN of the lambda creating an authentication challengestring""no
lambda_config_custom_email_senderA custom email sender AWS Lambda triggermap(any){}no
lambda_config_custom_messageAWS Lambda trigger custom messagestring""no
lambda_config_custom_sms_senderA custom SMS sender AWS Lambda triggermap(any){}no
lambda_config_define_auth_challengeAuthentication challengestring""no
lambda_config_kms_key_idThe Amazon Resource Name of Key Management Service Customer master keys. Amazon Cognito uses the key to encrypt codes and temporary passwords sent to CustomEmailSender and CustomSMSSender.stringnullno
lambda_config_post_authenticationA post-authentication AWS Lambda triggerstring""no
lambda_config_post_confirmationA post-confirmation AWS Lambda triggerstring""no
lambda_config_pre_authenticationA pre-authentication AWS Lambda triggerstring""no
lambda_config_pre_sign_upA pre-registration AWS Lambda triggerstring""no
lambda_config_pre_token_generationAllow to customize identity token claims before token generationstring""no
lambda_config_user_migrationThe user migration Lambda config typestring""no
lambda_config_verify_auth_challenge_responseVerifies the authentication challenge responsestring""no
mfa_configurationMulti-factor authentication configuration. Must be one of the following values (ON, OFF, OPTIONAL)string"OFF"no
nameID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.
This is the only ID element not also included as a tag.
The "name" tag is set to the full id string. There is no tag with the value of the name input.
namespaceID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally uniquestringnullno
number_schemasA container with the number schema attributes of a user pool. Maximum of 50 attributeslist(any)[]no
password_policyUser Pool password policy configuration
minimum_length = number,
require_lowercase = bool,
require_numbers = bool,
require_symbols = bool,
require_uppercase = bool,
temporary_password_validity_days = number
password_policy_minimum_lengthThe minimum password lengthnumber8no
password_policy_require_lowercaseWhether you have required users to use at least one lowercase letter in their passwordbooltrueno
password_policy_require_numbersWhether you have required users to use at least one number in their passwordbooltrueno
password_policy_require_symbolsWhether you have required users to use at least one symbol in their passwordbooltrueno
password_policy_require_uppercaseWhether you have required users to use at least one uppercase letter in their passwordbooltrueno
password_policy_temporary_password_validity_daysPassword policy temporary password validity_daysnumber7no
recovery_mechanismsList of account recovery optionslist(any)[]no
regex_replace_charsTerraform regular expression (regex) string.
Characters matching the regex will be removed from the ID elements.
If not set, "/[^a-zA-Z0-9-]/" is used to remove all characters other than hyphens, letters and digits.
regionAWS regionstringn/ayes
resource_server_identifierResource server identifierstringnullno
resource_server_nameResource server namestringnullno
resource_server_scope_descriptionResource server scope descriptionstringnullno
resource_server_scope_nameResource server scope namestringnullno
resource_serversResource servers configurationlist(any)[]no
schemasA container with the schema attributes of a User Pool. Maximum of 50 attributeslist(any)[]no
sms_authentication_messageA string representing the SMS authentication messagestringnullno
sms_configurationSMS configurationmap(any){}no
sms_configuration_external_idThe external ID used in IAM role trust relationshipsstring""no
sms_configuration_sns_caller_arnThe ARN of the Amazon SNS caller. This is usually the IAM role that you've given Cognito permission to assumestring""no
sms_verification_messageA string representing the SMS verification messagestringnullno
software_token_mfa_configurationConfiguration block for software token MFA. mfa_configuration must also be enabled for this to workmap(any){}no
software_token_mfa_configuration_enabledIf true, and if mfa_configuration is also enabled, multi-factor authentication by software TOTP generator will be enabledboolfalseno
stageID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release'stringnullno
string_schemasA container with the string schema attributes of a user pool. Maximum of 50 attributeslist(any)[]no
tagsAdditional tags (e.g. {'BusinessUnit': 'XYZ'}).
Neither the tag keys nor the tag values will be modified by this module.
temporary_password_validity_daysThe user account expiration limit, in days, after which the account is no longer usablenumber7no
tenantID element _(Rarely used, not included by default)_. A customer identifier, indicating who this instance of a resource is forstringnullno
user_group_descriptionThe description of the user groupstringnullno
user_group_nameThe name of the user groupstringnullno
user_group_precedenceThe precedence of the user groupnumbernullno
user_group_role_arnThe ARN of the IAM role to be associated with the user groupstringnullno
user_groupsUser groups configurationlist(any)[]no
user_pool_add_onsConfiguration block for user pool add-ons to enable user pool advanced security mode featuresmap(any){}no
user_pool_add_ons_advanced_security_modeThe mode for advanced security, must be one of OFF, AUDIT or ENFORCEDstringnullno
user_pool_nameUser pool name. If not provided, the name will be generated from the contextstringnullno
username_attributesSpecifies whether email addresses or phone numbers can be specified as usernames when a user signs up. Conflicts with alias_attributeslist(string)nullno
username_configurationThe Username Configuration. Setting case_sensitive specifies whether username case sensitivity will be applied for all users in the user pool through Cognito APIsmap(any){}no
verification_message_templateThe verification message templates configurationmap(any){}no
verification_message_template_default_email_optionThe default email option. Must be either CONFIRM_WITH_CODE or CONFIRM_WITH_LINK. Defaults to CONFIRM_WITH_CODEstringnullno
verification_message_template_email_message_by_linkThe email message template for sending a confirmation link to the user, it must contain the {##Click Here##} placeholderstringnullno
verification_message_template_email_subject_by_linkThe subject line for the email message template for sending a confirmation link to the userstringnullno


arnThe ARN of the User Pool
client_idsThe ids of the User Pool clients
client_ids_mapThe IDs map of the User Pool clients
client_secretsThe client secrets of the User Pool clients
client_secrets_mapThe client secrets map of the User Pool clients
creation_dateThe date the User Pool was created
domain_app_versionThe app version for the domain
domain_aws_account_idThe AWS account ID for the User Pool domain
domain_cloudfront_distribution_arnThe ARN of the CloudFront distribution for the domain
domain_s3_bucketThe S3 bucket where the static files for the domain are stored
endpointThe endpoint name of the User Pool. Example format:
idThe ID of the User Pool
last_modified_dateThe date the User Pool was last modified
resource_servers_scope_identifiersA list of all scopes configured in the format identifier/scope_name