module "cognito" {
  source = "../modules/cognito"

  depends_on = [
    module.lambda
  ]

  providers = {
    aws = aws.aws
  }

  redirect_url = local.domain
  name         = "cognito-userpool"
  domain       = "santilococo"
  client_name  = "cognito-client"

  alias_attributes = [
    "email",
    "preferred_username",
  ]

  auto_verified_attributes = [
    "email"
  ]

  account_recovery_mechanisms = [
    {
      name     = "verified_email"
      priority = 1
    }
  ]

  password_minimum_length    = 10
  password_require_lowercase = true
  password_require_numbers   = true
  password_require_uppercase = true
  password_require_symbols   = true

  temporary_password_validity_days = 3

  enable_username_case_sensitivity = false

  schema_attributes = [
    {
      type                     = "String"
      developer_only_attribute = false
      mutable                  = true
      name                     = "email"
      required                 = true
    }
  ]

  lambda_pre_sign_up   = module.lambda["lambdaTopicSNS"].function_arn
  lambda_function_name = module.lambda["lambdaTopicSNS"].function_name
}
