pra*_*HiC 4 amazon-web-services amazon-cognito terraform terraform-provider-aws
我正在尝试使用 Terraform 创建新的 AWS Cognito 用户池,目前遇到以下问题:
我一直在尝试获取电子邮件地址或电话号码->允许选择电子邮件地址(如下以红色显示),而不是当前选择的地址(用户名->还允许使用经过验证的电子邮件地址登录)
我的文件的相关部分main.tf如下所示:
resource "aws_cognito_user_pool" "app_cognito_user_pool" {
name = "app_cognito_user_pool"
alias_attributes = ["email"]
auto_verified_attributes = ["email"]
account_recovery_setting {
recovery_mechanism {
name = "verified_email"
priority = 1
}
}
}
resource "aws_cognito_user_pool_client" "app_cognito_user_pool_client" {
name = "app_cognito_user_pool_client"
user_pool_id = aws_cognito_user_pool.app_cognito_user_pool.id
prevent_user_existence_errors = "ENABLED"
supported_identity_providers = ["COGNITO"]
}
resource "aws_cognito_user_pool_domain" "app_cognito_user_pool_domain" {
domain = "app"
user_pool_id = aws_cognito_user_pool.app_cognito_user_pool.id
}
Run Code Online (Sandbox Code Playgroud)
无论我尝试什么,我总是选择Username,而不是电子邮件地址或电话号码。我希望用户池不要使用用户名,而是使用电子邮件地址。
我缺少哪些 Terraform 参数或值?
只设置username_attributes和不alias_attributes设置["email"]。
设置alias_attributes指定“顶部部分”,即同时使用经过验证的电子邮件地址/电话号码登录。
除了用户名之外,它还指定您可以登录的额外(别名)方式。
\n设置username_attributes指定“底部部分”,即允许电子邮件地址/电话号码/电子邮件地址和电话号码...
它指定使用什么来代替用户名。
\n取消设置alias_attributes(因为它与 冲突username_attributes)然后将 `username_attributes\' 设置为以下之一:
[\xe2\x80\x9cemail\xe2\x80\x9d]-允许电子邮件地址[\xe2\x80\x9cphone_number\xe2\x80\x9d]-允许电话号码[\xe2\x80\x9cemail\xe2\x80\x9d, \xe2\x80\x9cphone_number\xe2\x80\x9d]-允许电子邮件地址和电话号码(用户可以选择一个)对于您的情况,您需要设置username_attributes为["email"]。
这应该有效:
\nresource "aws_cognito_user_pool" "app_cognito_user_pool" {\n name = "app_cognito_user_pool"\n\n username_attributes = ["email"]\n auto_verified_attributes = ["email"]\n account_recovery_setting {\n recovery_mechanism {\n name = "verified_email"\n priority = 1\n }\n }\n}\n...\nRun Code Online (Sandbox Code Playgroud)\n