使用 terraform 创建 aws cognito 用户池会禁用电子邮件验证

Creating aws cognito user pool using terraform disables email validation

我正在使用 terraform 0.12.20 创建一个认知用户池。

我想通过向用户电子邮件发送代码来启用电子邮件验证。我可以在 UI 中看到如何执行此操作,但不使用 terraform。 Cognito API 文档似乎没有任何关于启用验证的参考。

我的地形资源是:

resource "aws_cognito_user_pool" "pool" {
  name = "pool"

  username_attributes = ["email"]

  lambda_config {
    pre_sign_up = var.pre_sign_up_lambda.arn
  }

  verification_message_template {
    default_email_option = "CONFIRM_WITH_CODE"
  }

  email_configuration {
    email_sending_account = "COGNITO_DEFAULT"
  }

  password_policy {
    minimum_length    = 8
    require_lowercase = true
    require_numbers   = true
    require_symbols   = true
    require_uppercase = true
  }
}

经过反复试验,我似乎对文档的理解有误。

aws_cognito_user_pool 资源中有一个 auto_verified_attributes。这是您要为其启用验证的属性列表。

例如,在我上面的资源中,我需要添加 auto_verified_attributes = ["email"] 以使用代码启用电子邮件验证。

我也有同样的问题,auto_verified_attributes 也对我有用,但文档说的有些不同:

auto_verified_attributes -(可选)要自动验证的属性。可能的值:电子邮件、phone_number.