如何在terraform中启用Cognito“属性验证和用户帐户确认”

问题描述 投票:0回答:1

这是我用来创建 Cognito 用户池的 terraform 脚本:


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
}

但后来我手动添加了属性验证和用户帐户确认,如图所示。我需要的是将图片中的内容添加到我的 terraform 脚本中

我正在阅读文档,但我还没有标识它

amazon-web-services terraform terraform-provider-aws terraform-aws-modules
1个回答
0
投票

这个问题的解决方案是将电子邮件添加为自动验证的属性,如下所示:

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"]

}
© www.soinside.com 2019 - 2024. All rights reserved.