我已经在 AWS Route53 中创建了一个区域,如下所示
resource "aws_route53_zone" "my-app" {
name = "${var.zone_name}"
}
data "aws_route53_zone" "selected" {
name = "appgggghello.com."
}
output "ns" {
value = "${data.aws_route53_zone.selected.name_servers}"
}
它将显示如下内容
ns = [
ns-754.awsdns-350.net,
ns-555.awsdns-0553.org,
ns-555.awsdns-25552.co.uk,
ns-45569.awsdns-55555.com
]
现在我的问题是如何在 Cloudfalre 中使用此 NS 输出作为输入
resource "cloudflare_record" "aws-ns-record" {
domain = "${var.domain}"
name = "appgggghello.com"
value = ["${data.aws_route53_zone.selected.name_servers}"]
type = "NS"
priority = 1
}
在 Route53 中我可以使用设置 NS
records = ["${data.aws_route53_zone.selected.name_servers}"]
请告诉我如何才能实现这一目标?
答案1
cloudflare_record
采用字符串作为值而不是列表
value - (Optional) The (string) value of the record. Either this or data must be specified
所以我们需要在其中添加计数
现在我有个问题,我如何才能像这里一样在 Cloudfalre 中使用此 NS 输出作为输入。然后根据计数将元素从列表中拉出
resource "cloudflare_record" "aws-ns-record" {
count = "${length(data.aws_route53_zone.selected.name_servers)}"
domain = "${var.domain}"
name = "appgggghello.com"
value = "${element(data.aws_route53_zone.selected.name_servers, count.index)}"
type = "NS"
priority = 1
}