This component is responsible for provisioning and managing AWS Cognito resources.
This component can provision the following resources:
- Cognito User Pools
- Cognito User Pool Clients
- Cognito User Pool Domains
- Cognito User Pool Identity Providers
- Cognito User Pool Resource Servers
- Cognito User Pool User Groups
Stack Level: Global
Here's an example snippet for how to use this component:
components:
terraform:
cognito:
settings:
spacelift:
workspace_enabled: true
vars:
enabled: true
# The full name of the User Pool will be: <namespace>-<environment>-<stage>-<name>
name: cognito
schemas:
- name: "email"
attribute_data_type: "String"
developer_only_attribute: false
mutable: false
required: true
Name | Version |
---|---|
terraform | >= 1.0.0 |
aws | >= 4.8.0 |
Name | Version |
---|---|
aws | >= 4.8.0 |
Name | Source | Version |
---|---|---|
iam_roles | ../account-map/modules/iam-roles | n/a |
this | cloudposse/label/null | 0.25.0 |
Name | Type |
---|---|
aws_cognito_identity_provider.identity_provider | resource |
aws_cognito_resource_server.resource | resource |
aws_cognito_user_group.main | resource |
aws_cognito_user_pool.pool | resource |
aws_cognito_user_pool_client.client | resource |
aws_cognito_user_pool_domain.domain | resource |
Name | Description | Type | Default | Required |
---|---|---|---|---|
additional_tag_map | Additional 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. |
map(string) |
{} |
no |
admin_create_user_config | The configuration for AdminCreateUser requests | map(any) |
{} |
no |
admin_create_user_config_allow_admin_create_user_only | Set to true if only the administrator is allowed to create user profiles. Set to false if users can sign themselves up via an app |
bool |
true |
no |
admin_create_user_config_email_message | The message template for email messages. Must contain {username} and {####} placeholders, for username and temporary password, respectively |
string |
"{username}, your temporary password is {####}" |
no |
admin_create_user_config_email_subject | The subject line for email messages | string |
"Your verification code" |
no |
admin_create_user_config_sms_message | The message template for SMS messages. Must contain {username} and {####} placeholders, for username and temporary password, respectively |
string |
"Your username is {username} and temporary password is {####}" |
no |
alias_attributes | Attributes supported as an alias for this user pool. Possible values: phone_number, email, or preferred_username. Conflicts with username_attributes |
list(string) |
null |
no |
attributes | ID 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. |
list(string) |
[] |
no |
auto_verified_attributes | The attributes to be auto-verified. Possible values: email, phone_number | list(string) |
[] |
no |
client_access_token_validity | Time 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 . |
number |
60 |
no |
client_allowed_oauth_flows | List of allowed OAuth flows (code, implicit, client_credentials) | list(string) |
[] |
no |
client_allowed_oauth_flows_user_pool_client | Whether the client is allowed to follow the OAuth protocol when interacting with Cognito user pools | bool |
true |
no |
client_allowed_oauth_scopes | List of allowed OAuth scopes (phone, email, openid, profile, and aws.cognito.signin.user.admin) | list(string) |
[] |
no |
client_callback_urls | List of allowed callback URLs for the identity providers | list(string) |
[] |
no |
client_default_redirect_uri | The default redirect URI. Must be in the list of callback URLs | string |
"" |
no |
client_explicit_auth_flows | List of authentication flows (ADMIN_NO_SRP_AUTH, CUSTOM_AUTH_FLOW_ONLY, USER_PASSWORD_AUTH) | list(string) |
[] |
no |
client_generate_secret | Should an application secret be generated | bool |
true |
no |
client_id_token_validity | Time 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 . |
number |
60 |
no |
client_logout_urls | List of allowed logout URLs for the identity providers | list(string) |
[] |
no |
client_name | The name of the application client | string |
null |
no |
client_prevent_user_existence_errors | Choose 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. | string |
null |
no |
client_read_attributes | List of user pool attributes the application client can read from | list(string) |
[] |
no |
client_refresh_token_validity | The 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_units |
number |
30 |
no |
client_supported_identity_providers | List of provider names for the identity providers that are supported on this client | list(string) |
[] |
no |
client_token_validity_units | Configuration block for units in which the validity times are represented in. Valid values for the following arguments are: seconds , minutes , hours or days . |
any |
{ |
no |
client_write_attributes | List of user pool attributes the application client can write to | list(string) |
[] |
no |
clients | User Pool clients configuration | any |
[] |
no |
context | Single 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. |
any |
{ |
no |
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 |
delimiter | Delimiter to be used between ID elements. Defaults to - (hyphen). Set to "" to use no delimiter at all. |
string |
null |
no |
descriptor_formats | Describe 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 beidentical to how they appear in id .Default is {} (descriptors output will be empty). |
any |
{} |
no |
device_configuration | The configuration for the user pool's device tracking | map(any) |
{} |
no |
device_configuration_challenge_required_on_new_device | Indicates whether a challenge is required on a new device. Only applicable to a new device | bool |
false |
no |
device_configuration_device_only_remembered_on_user_prompt | If true, a device is only remembered on user prompt | bool |
false |
no |
domain | Cognito User Pool domain | string |
null |
no |
domain_certificate_arn | The ARN of an ISSUED ACM certificate in us-east-1 for a custom domain |
string |
null |
no |
email_configuration | Email configuration | map(any) |
{} |
no |
email_configuration_email_sending_account | Instruct Cognito to either use its built-in functionality or Amazon SES to send out emails. Allowed values: COGNITO_DEFAULT or DEVELOPER |
string |
"COGNITO_DEFAULT" |
no |
email_configuration_from_email_address | Senderβ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 5322 |
string |
null |
no |
email_configuration_reply_to_email_address | The REPLY-TO email address | string |
"" |
no |
email_configuration_source_arn | The ARN of the email configuration source | string |
"" |
no |
email_verification_message | A string representing the email verification message | string |
null |
no |
email_verification_subject | A string representing the email verification subject | string |
null |
no |
enabled | Set to false to prevent the module from creating any resources | bool |
null |
no |
environment | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | string |
null |
no |
id_length_limit | Limit 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 . |
number |
null |
no |
identity_providers | Cognito Identity Providers configuration | list(any) |
[] |
no |
label_key_case | Controls 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 . |
string |
null |
no |
label_order | The 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. |
list(string) |
null |
no |
label_value_case | Controls 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 . |
string |
null |
no |
labels_as_tags | Set 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.Notes: 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 bechanged in later chained modules. Attempts to change it will be silently ignored. |
set(string) |
[ |
no |
lambda_config | Configuration for the AWS Lambda triggers associated with the User Pool | any |
null |
no |
lambda_config_create_auth_challenge | The ARN of the lambda creating an authentication challenge | string |
"" |
no |
lambda_config_custom_email_sender | A custom email sender AWS Lambda trigger | map(any) |
{} |
no |
lambda_config_custom_message | AWS Lambda trigger custom message | string |
"" |
no |
lambda_config_custom_sms_sender | A custom SMS sender AWS Lambda trigger | map(any) |
{} |
no |
lambda_config_define_auth_challenge | Authentication challenge | string |
"" |
no |
lambda_config_kms_key_id | The 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. | string |
null |
no |
lambda_config_post_authentication | A post-authentication AWS Lambda trigger | string |
"" |
no |
lambda_config_post_confirmation | A post-confirmation AWS Lambda trigger | string |
"" |
no |
lambda_config_pre_authentication | A pre-authentication AWS Lambda trigger | string |
"" |
no |
lambda_config_pre_sign_up | A pre-registration AWS Lambda trigger | string |
"" |
no |
lambda_config_pre_token_generation | Allow to customize identity token claims before token generation | string |
"" |
no |
lambda_config_user_migration | The user migration Lambda config type | string |
"" |
no |
lambda_config_verify_auth_challenge_response | Verifies the authentication challenge response | string |
"" |
no |
mfa_configuration | Multi-factor authentication configuration. Must be one of the following values (ON, OFF, OPTIONAL) | string |
"OFF" |
no |
name | ID 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. |
string |
null |
no |
namespace | ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique | string |
null |
no |
number_schemas | A container with the number schema attributes of a user pool. Maximum of 50 attributes | list(any) |
[] |
no |
password_policy | User Pool password policy configuration | object({ |
null |
no |
password_policy_minimum_length | The minimum password length | number |
8 |
no |
password_policy_require_lowercase | Whether you have required users to use at least one lowercase letter in their password | bool |
true |
no |
password_policy_require_numbers | Whether you have required users to use at least one number in their password | bool |
true |
no |
password_policy_require_symbols | Whether you have required users to use at least one symbol in their password | bool |
true |
no |
password_policy_require_uppercase | Whether you have required users to use at least one uppercase letter in their password | bool |
true |
no |
password_policy_temporary_password_validity_days | Password policy temporary password validity_days | number |
7 |
no |
recovery_mechanisms | List of account recovery options | list(any) |
[] |
no |
regex_replace_chars | Terraform 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. |
string |
null |
no |
region | AWS region | string |
n/a | yes |
resource_server_identifier | Resource server identifier | string |
null |
no |
resource_server_name | Resource server name | string |
null |
no |
resource_server_scope_description | Resource server scope description | string |
null |
no |
resource_server_scope_name | Resource server scope name | string |
null |
no |
resource_servers | Resource servers configuration | list(any) |
[] |
no |
schemas | A container with the schema attributes of a User Pool. Maximum of 50 attributes | list(any) |
[] |
no |
sms_authentication_message | A string representing the SMS authentication message | string |
null |
no |
sms_configuration | SMS configuration | map(any) |
{} |
no |
sms_configuration_external_id | The external ID used in IAM role trust relationships | string |
"" |
no |
sms_configuration_sns_caller_arn | The ARN of the Amazon SNS caller. This is usually the IAM role that you've given Cognito permission to assume | string |
"" |
no |
sms_verification_message | A string representing the SMS verification message | string |
null |
no |
software_token_mfa_configuration | Configuration block for software token MFA. mfa_configuration must also be enabled for this to work |
map(any) |
{} |
no |
software_token_mfa_configuration_enabled | If true , and if mfa_configuration is also enabled, multi-factor authentication by software TOTP generator will be enabled |
bool |
false |
no |
stage | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | string |
null |
no |
string_schemas | A container with the string schema attributes of a user pool. Maximum of 50 attributes | list(any) |
[] |
no |
tags | Additional tags (e.g. {'BusinessUnit': 'XYZ'} ).Neither the tag keys nor the tag values will be modified by this module. |
map(string) |
{} |
no |
temporary_password_validity_days | The user account expiration limit, in days, after which the account is no longer usable | number |
7 |
no |
tenant | ID element _(Rarely used, not included by default)_. A customer identifier, indicating who this instance of a resource is for | string |
null |
no |
user_group_description | The description of the user group | string |
null |
no |
user_group_name | The name of the user group | string |
null |
no |
user_group_precedence | The precedence of the user group | number |
null |
no |
user_group_role_arn | The ARN of the IAM role to be associated with the user group | string |
null |
no |
user_groups | User groups configuration | list(any) |
[] |
no |
user_pool_add_ons | Configuration block for user pool add-ons to enable user pool advanced security mode features | map(any) |
{} |
no |
user_pool_add_ons_advanced_security_mode | The mode for advanced security, must be one of OFF , AUDIT or ENFORCED |
string |
null |
no |
user_pool_name | User pool name. If not provided, the name will be generated from the context | string |
null |
no |
username_attributes | Specifies whether email addresses or phone numbers can be specified as usernames when a user signs up. Conflicts with alias_attributes |
list(string) |
null |
no |
username_configuration | The Username Configuration. Setting case_sensitive specifies whether username case sensitivity will be applied for all users in the user pool through Cognito APIs |
map(any) |
{} |
no |
verification_message_template | The verification message templates configuration | map(any) |
{} |
no |
verification_message_template_default_email_option | The default email option. Must be either CONFIRM_WITH_CODE or CONFIRM_WITH_LINK . Defaults to CONFIRM_WITH_CODE |
string |
null |
no |
verification_message_template_email_message_by_link | The email message template for sending a confirmation link to the user, it must contain the {##Click Here##} placeholder |
string |
null |
no |
verification_message_template_email_subject_by_link | The subject line for the email message template for sending a confirmation link to the user | string |
null |
no |
Name | Description |
---|---|
arn | The ARN of the User Pool |
client_ids | The ids of the User Pool clients |
client_ids_map | The IDs map of the User Pool clients |
client_secrets | The client secrets of the User Pool clients |
client_secrets_map | The client secrets map of the User Pool clients |
creation_date | The date the User Pool was created |
domain_app_version | The app version for the domain |
domain_aws_account_id | The AWS account ID for the User Pool domain |
domain_cloudfront_distribution_arn | The ARN of the CloudFront distribution for the domain |
domain_s3_bucket | The S3 bucket where the static files for the domain are stored |
endpoint | The endpoint name of the User Pool. Example format: cognito-idp.REGION.amazonaws.com/xxxx_yyyyy |
id | The ID of the User Pool |
last_modified_date | The date the User Pool was last modified |
resource_servers_scope_identifiers | A list of all scopes configured in the format identifier/scope_name |
- cloudposse/terraform-aws-components - Cloud Posse's upstream component
Tip
Cloud Posse uses atmos
to easily orchestrate multiple environments using Terraform.
Works with Github Actions, Atlantis, or Spacelift.
Watch demo of using Atmos with Terraform
Example of running
atmos
to manage infrastructure from our Quick Start tutorial.
Check out these related projects.
- Cloud Posse Terraform Modules - Our collection of reusable Terraform modules used by our reference architectures.
- Atmos - Atmos is like docker-compose but for your infrastructure
Tip
Use Cloud Posse's ready-to-go terraform architecture blueprints for AWS to get up and running quickly.
β
We build it together with your team.
β
Your team owns everything.
β
100% Open Source and backed by fanatical support.
π Learn More
Cloud Posse is the leading DevOps Accelerator for funded startups and enterprises.
Your team can operate like a pro today.
Ensure that your team succeeds by using Cloud Posse's proven process and turnkey blueprints. Plus, we stick around until you succeed.
- Reference Architecture. You'll get everything you need from the ground up built using 100% infrastructure as code.
- Deployment Strategy. Adopt a proven deployment strategy with GitHub Actions, enabling automated, repeatable, and reliable software releases.
- Site Reliability Engineering. Gain total visibility into your applications and services with Datadog, ensuring high availability and performance.
- Security Baseline. Establish a secure environment from the start, with built-in governance, accountability, and comprehensive audit logs, safeguarding your operations.
- GitOps. Empower your team to manage infrastructure changes confidently and efficiently through Pull Requests, leveraging the full power of GitHub Actions.
- Training. Equip your team with the knowledge and skills to confidently manage the infrastructure, ensuring long-term success and self-sufficiency.
- Support. Benefit from a seamless communication over Slack with our experts, ensuring you have the support you need, whenever you need it.
- Troubleshooting. Access expert assistance to quickly resolve any operational challenges, minimizing downtime and maintaining business continuity.
- Code Reviews. Enhance your teamβs code quality with our expert feedback, fostering continuous improvement and collaboration.
- Bug Fixes. Rely on our team to troubleshoot and resolve any issues, ensuring your systems run smoothly.
- Migration Assistance. Accelerate your migration process with our dedicated support, minimizing disruption and speeding up time-to-value.
- Customer Workshops. Engage with our team in weekly workshops, gaining insights and strategies to continuously improve and innovate.
This project is under active development, and we encourage contributions from our community.
Many thanks to our outstanding contributors:
For π bug reports & feature requests, please use the issue tracker.
In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.
- Review our Code of Conduct and Contributor Guidelines.
- Fork the repo on GitHub
- Clone the project to your own machine
- Commit changes to your own branch
- Push your work back up to your fork
- Submit a Pull Request so that we can review your changes
NOTE: Be sure to merge the latest changes from "upstream" before making a pull request!
Join our Open Source Community on Slack. It's FREE for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally sweet infrastructure.
Sign up for our newsletter and join 3,000+ DevOps engineers, CTOs, and founders who get insider access to the latest DevOps trends, so you can always stay in the know. Dropped straight into your Inbox every week β and usually a 5-minute read.
Join us every Wednesday via Zoom for your weekly dose of insider DevOps trends, AWS news and Terraform insights, all sourced from our SweetOps community, plus a live Q&A that you canβt find anywhere else. It's FREE for everyone!
Preamble to the Apache License, Version 2.0
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
All other trademarks referenced herein are the property of their respective owners.
Copyright Β© 2017-2024 Cloud Posse, LLC