Amazon web services Cognito自己的域名需要一个记录
我试图为Cognito的用户池分配一个自己的域名,并且面临一个似乎需要记录的问题 在我的例子中,我已经在我的internet域上注册了通配符,并尝试按照中提到的步骤进行操作 现在我可以创建一个A记录,但不知道A记录应该指向哪里。欢迎提供任何提示或提示:)如果不使用CloudFront也能做到这一点,那就太好了 我尝试了CNAME的etc,但如前所述,需要记录 您拥有的web域。其根目录必须在DNS中具有有效的a记录Amazon web services Cognito自己的域名需要一个记录,amazon-web-services,amazon-cognito,aws-cognito,Amazon Web Services,Amazon Cognito,Aws Cognito,我试图为Cognito的用户池分配一个自己的域名,并且面临一个似乎需要记录的问题 在我的例子中,我已经在我的internet域上注册了通配符,并尝试按照中提到的步骤进行操作 现在我可以创建一个A记录,但不知道A记录应该指向哪里。欢迎提供任何提示或提示:)如果不使用CloudFront也能做到这一点,那就太好了 我尝试了CNAME的etc,但如前所述,需要记录 您拥有的web域。其根目录必须在DNS中具有有效的a记录 简而言之,如果您的域是example.com,则在继续之前,需要为网站实际配置根
简而言之,如果您的域是
example.com
,则在继续之前,需要为网站实际配置根--example.com
。记录的特定值和Cognito无关,因为这取决于您选择如何设置站点。。。但是Cognito要求它存在。似乎试图使用带有太多点的子域会导致这种错误
这项工作:
auth.example.com
这并不是:
dev.auth.example.com
此外,如果您删除并重新添加相同的域名,这似乎会导致错误。更改到另一个域是有效的
我在#awswishlist中添加了一个修复此问题的请求,与此相关的不是域根。它是位于您输入的级别下方的子域
- 如果输入
,则需要一个auth.example.com
example.com
- 如果输入
,则需要一条A记录 对于auth.qa.example.com
qa.example.com
- 如果您输入
您需要foo.bar.qa.example.com
bar.qa.example.com
为了处理子域,我用IP
127.0.0.1
创建了一个记录,它正在工作
我想在cognito中添加auth.dev.${domain_name}.com
作为自定义域,但我没有指向dev.${domain_name}.com
的任何网站,因此为dev.${domain_name}.com创建了一个记录,并指向127.0.0.1
ip地址
流行的答案正确地回答了这个问题。但在更高的层次上,还有更多的东西。配置依赖项中存在一个循环: Cognito需要
auth.example.com
A记录,这需要example.com
A记录。example.com
记录需要指向一个网站,而该网站需要Cognito
要打破这个循环,
auth.example.com
,供Cognito独立于网站的example.com
区域使用。这打破了依赖循环auth.example.com
记录,指向一个占位符IP地址,如127.0.0.1
。这将永远不会被实际使用dev.auth.example.com
、stage.auth.example.com
或prod.auth.example.com
prod.auth.example.com
:
# Pre-existing hosted zone created by Route53 Registrar
data "aws_route53_zone" "main" {
name = "example.com"
}
# Create a new Route 53 zone auth.example.com
#
# Actually, Route 53 zone creation belongs in a separate Terraform
# module where it can be shared by multiple environments.
resource "aws_route53_zone" "auth" {
name = "auth.example.com"
}
resource "aws_route53_record" "auth-ns" {
zone_id = data.aws_route53_zone.main.zone_id
name = "auth.example.com"
type = "NS"
ttl = "30"
records = aws_route53_zone.auth.name_servers
} As it is now,
# `terraform destroy` will destroy zone auth.example.com, leaving the other environments in the lurch.
# Only the name servers in the auth.example.com zone NS record know where
# to find auth.example.com. Add NS record in example.com pointing to the
# auth.example.com zone name servers. Now auth.example.com can
# be found through example.com.
resource "aws_route53_record" "auth-a" {
zone_id = aws_route53_zone.auth.zone_id
name = "auth.example.com"
type = "A"
ttl = 300
records = ["127.0.0.1"] # Placeholder that is never used
}
# Route 53 zone auth.example.com setup done
module "acm" {
source = "terraform-aws-modules/acm/aws"
domain_name = "prod.auth.example.com"
zone_id = aws_route53_zone.auth.zone_id
subject_alternative_names = []
wait_for_validation = true
}
resource "aws_cognito_user_pool" "this" {
name = "prod-cognito"
}
resource "aws_cognito_user_pool_domain" "this" {
depends_on = [aws_route53_record.auth-a]
domain = "prod.auth.example.com"
certificate_arn = module.acm.this_acm_certificate_arn
user_pool_id = aws_cognito_user_pool.this.id
}
resource "aws_route53_record" "subdomain-a" {
zone_id = aws_route53_zone.auth.zone_id
name = "prod.auth.example.com"
type = "A"
alias {
evaluate_target_health = false
name = aws_cognito_user_pool_domain.this.cloudfront_distribution_arn
# Every CloudFront distribution's zone ID is Z2FDTNDATAQYW2
zone_id = "Z2FDTNDATAQYW2"
}
}
还有一点工作要做:您还需要使用aws\u cognito\u user\u pool\u client
创建应用程序客户端。我忽略了这一点,因为应用程序客户端与自定义域无关
更新:我发现我可以更好地隔离
通过为每个环境创建托管分区来创建环境,如
dev auth.example.com
,stage auth.example.com
和
auth.example.com
。没有必要再费心处理更多的子域
下面是这些。我知道您正在使用Cognito托管的UI进行身份验证,并且您需要一个自定义域 当您为cognito创建自定义域时,它将返回一个别名目标(指向cloudfront发行版) 然后根据您使用的是Route53还是DNS配置,采取以下步骤: DNS配置
- a。选择“创建托管区域”
- b。从域名列表中选择您的自定义域
- c。在“注释”中,键入有关托管分区的可选注释
- d。选择创建
- a。在“托管区域”页面上,选择托管区域的名称
- b。选择“创建记录集”,然后输入以下值:
- 一,。请键入首选子域名作为“名称”。例如,如果您尝试创建的子域是auth.example.com,请键入auth
- 二,。对于类型,请选择-IPv4地址
- iii.为别名选项选择“是”
- iv.键入您在alias target的上一步中注意到的别名目标名称
- c。选择创建
参考资料:为什么这是一项要求?我的网站位于
www