// Copyright 2022 Amazon.com and its affiliates; all rights reserved. // SPDX-License-Identifier: MIT No Attribution terraform { required_providers { aws = { source = "hashicorp/aws" configuration_aliases = [aws] } } } resource "aws_cognito_user_pool" "user_pool" { name = "${var.APP}-${var.ENV}-${var.USER_POOL_NAME}" username_configuration { case_sensitive = false } admin_create_user_config { allow_admin_create_user_only = false invite_message_template { email_subject = "${var.APP_TITLE} User Invitation" email_message = "
Hello,

Welcome to ${var.APP_TITLE}. Kindly find the credentials for the account created for you.

User Email: {username}
Password: {####}

Please visit the login page, and enter the user email and password provided to login.

${var.APP_TITLE} Team " sms_message = "Hello,\r\nWelcome to ${var.APP_TITLE}.\r\nUser Email: {username}\r\nTemporary Password: {####}\r\n${var.APP_TITLE} Team" } } password_policy { minimum_length = 8 require_lowercase = true require_uppercase = true require_numbers = false require_symbols = false temporary_password_validity_days = 1 } username_attributes = ["email"] auto_verified_attributes = ["email"] verification_message_template { default_email_option = "CONFIRM_WITH_CODE" email_subject = "${var.APP_TITLE} User Email Verification" email_message = "
Hello,

Welcome to ${var.APP_TITLE}. You are kindly requested to verify your email using the code: {####}. Please visit login page, click on verify button, enter your email id and the code provided and click verify.

${var.APP_TITLE} Team " } mfa_configuration = "OFF" schema { attribute_data_type = "String" developer_only_attribute = false mutable = true name = "email" required = false string_attribute_constraints {} } } resource "aws_iam_role" "group_role" { name = "${var.APP}-${var.ENV}-${var.REGION}-cognito-user-group-role" assume_role_policy = <