This is the terraform script that I use to create Cognito user pool:
resource "aws_cognito_user_pool" "user_pool" {
name = "${var.app_name}-user-pool"
username_attributes = ["email"]
verification_message_template {
default_email_option = "CONFIRM_WITH_CODE"
email_subject = "Account Confirmation"
email_message = "Your confirmation code is {####}"
}
}
resource "aws_cognito_user_pool_client" "client" {
name = "${var.app_name}-cognito-client"
user_pool_id = aws_cognito_user_pool.user_pool.id
generate_secret = false
refresh_token_validity = 90
prevent_user_existence_errors = "ENABLED"
explicit_auth_flows = [
"ALLOW_REFRESH_TOKEN_AUTH",
"ALLOW_USER_PASSWORD_AUTH",
"ALLOW_ADMIN_USER_PASSWORD_AUTH",
"ALLOW_CUSTOM_AUTH",
"ALLOW_USER_SRP_AUTH"
]
}
resource "aws_cognito_user_pool_domain" "cognito-domain" {
domain = "${var.app_name}userpooldomain"
user_pool_id = aws_cognito_user_pool.user_pool.id
}
But then I manually added the attribute verification and user account confirmation, like in the image. What I need is to add what's in the picture to my terraform script
I was reading the documentation but I haven't logo it yet
The solution to this question it's to add email as a auto verified attributes like this :
resource "aws_cognito_user_pool" "user_pool" {
name = "${var.app_name}-user-pool"
username_attributes = ["email"]
verification_message_template {
default_email_option = "CONFIRM_WITH_CODE"
email_subject = "Account Confirmation"
email_message = "Your confirmation code is {####}"
}
# this allow the verification message on email
auto_verified_attributes = ["email"]
}