ACM 证书跨账户 DNS 验证
我有 2 个 AWS 账户:dev
和 prod
。
在 prod
帐户中,我设置了一个 DNS 域 (example.com
),以及 2 个公共托管区域:example.com
和 <代码>prod.example.com。 2 还为这些域 internal.prod.example.com
和 eks.prod.example.com
颁发了 ACM 证书。这些证书已由 DNS 正确验证。
在 dev
帐户中,我创建了 2 个公共托管区域:dev.example.com
和 example.com
。我为 internal.dev.example.com
和 eks.dev.example.com
颁发了 2 个 ACM 证书,据我所知,需要使用 DNS 进行验证prod
帐户。
这些证书处于待处理状态。
我如何验证它们?
到目前为止我所做的:
我在
example.com
的prod
帐户中添加了一条名为dev.example.com
的 NS 记录托管区。 NS 记录的值是在dev
帐户中创建的dev.example.com
托管区域的值。这是在prod
中委托 R53 托管区域的所有权。请参阅此处< /a>.在
dev
帐户中,ACM 请求的域的CNAME
已添加到dev.example.com
托管区域中验证。
以下代码是如何在产品帐户上完成(和工作)的。
注意 - 这是我接管的代码,所以我不知道是否采取了任何手动步骤。
data "aws_route53_zone" "dns-zone" {
name = "${var.environment}.${var.zone_name}"
}
resource "aws_acm_certificate" "cert" {
domain_name = "*.${var.environment}.${var.zone_name}"
validation_method = "DNS"
subject_alternative_names = list("*.internal.${var.environment}.${var.zone_name}", "*.eks.${var.environment}.${var.zone_name}")
lifecycle {
create_before_destroy = true
prevent_destroy = true
}
}
resource "aws_route53_record" "cert_validation" {
for_each = {
for dvo in aws_acm_certificate.cert.domain_validation_options : dvo.domain_name => {
name = dvo.resource_record_name
record = dvo.resource_record_value
type = dvo.resource_record_type
zone_id = data.aws_route53_zone.dns-zone.zone_id
}
}
allow_overwrite = true
name = each.value.name
records = [each.value.record]
ttl = 60
type = each.value.type
zone_id = each.value.zone_id
}
resource "aws_acm_certificate_validation" "cert" {
certificate_arn = aws_acm_certificate.cert.arn
validation_record_fqdns = [for record in aws_route53_record.cert_validation : record.fqdn]
}
PS - 如果您需要更多说明,请告诉我。
I have 2 AWS accounts: dev
and prod
.
In the prod
account, I setup a DNS domain (example.com
), as well as 2 public Hosted Zone: example.com
and prod.example.com
. 2 ACM certificates are also issued for these domains internal.prod.example.com
and eks.prod.example.com
. Those certificates are correctly validated by DNS.
In the dev
account, I have created 2 public Hosted Zones: dev.example.com
and example.com
. I issued 2 ACM certificates for internal.dev.example.com
and eks.dev.example.com
which, as far as I understand need to be validated with the DNS in the prod
account.
These certificated are in pending state.
How can I validate them?
What I did so far:
I added a NS record called
dev.example.com
in theprod
account for theexample.com
Hosted Zone. The value of the NS record are the ones of thedev.example.com
Hosted Zone created in thedev
account. This is to delegate the ownership of the R53 Hosted Zone inprod
. See here.In the
dev
account, theCNAME
of the requested domain from ACM have been added in thedev.example.com
Hosted Zone for validation.
The following code is how it's been done (and working) on the prod account.
Note - this is a code that I took over, so I'm not aware if any manual steps have been taken.
data "aws_route53_zone" "dns-zone" {
name = "${var.environment}.${var.zone_name}"
}
resource "aws_acm_certificate" "cert" {
domain_name = "*.${var.environment}.${var.zone_name}"
validation_method = "DNS"
subject_alternative_names = list("*.internal.${var.environment}.${var.zone_name}", "*.eks.${var.environment}.${var.zone_name}")
lifecycle {
create_before_destroy = true
prevent_destroy = true
}
}
resource "aws_route53_record" "cert_validation" {
for_each = {
for dvo in aws_acm_certificate.cert.domain_validation_options : dvo.domain_name => {
name = dvo.resource_record_name
record = dvo.resource_record_value
type = dvo.resource_record_type
zone_id = data.aws_route53_zone.dns-zone.zone_id
}
}
allow_overwrite = true
name = each.value.name
records = [each.value.record]
ttl = 60
type = each.value.type
zone_id = each.value.zone_id
}
resource "aws_acm_certificate_validation" "cert" {
certificate_arn = aws_acm_certificate.cert.arn
validation_record_fqdns = [for record in aws_route53_record.cert_validation : record.fqdn]
}
Ps - Should you need more clarification, please let me know.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
开发与开发您有
example.com
的产品帐户吗?只有1个可以正常使用。无论 注册商 位于 example.com 的何处...该注册商只能使用其中 1 个托管区域中的名称服务器。您提到您有 2 个 ACM 证书:internal.dev.example.com 和eks.dev.example.com ...如果这些域是在 DEV 帐户中创建的,则应在 DEV 帐户中对其进行验证。
另外,我建议您在 ACM 中为
*.dev.example.com
& 创建 1 个通配符证书。验证 DEV 帐户中的 1。任何子域(例如 eks.dev.example.com)都可以使用它。dev & prod account you have
example.com
? Only 1 can be used properly. Wherever the registrar is for example.com ... that registrar can only use the name servers from 1 of those hosted zones.You mentioned you have 2 ACM certs for internal.dev.example.com & eks.dev.example.com ... those should be validated in the DEV Account if that's where their domains are created.
Also I recommend you just create 1 wild card cert in ACM for
*.dev.example.com
& validate that 1 in the DEV account. Any subdomains such as eks.dev.example.com will be able to use it.