我在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
]现在我要问的是,如何使用这个NS输出作为Cloudfalre的输入,就像这里
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中,我可以使用
records = ["${data.aws_route53_zone.selected.name_servers}"]请告诉我怎样才能做到这一点?
发布于 2019-05-03 00:41:50
cloudflare_record接受字符串作为值,而不是列表
value - (Optional) The (string) value of the record. Either this or data must be specified所以我们需要在里面加上一个计数
现在我要问的是,如何使用这个NS输出作为Cloudfalre的输入,就像这里一样。然后根据计数从列表中提取元素。
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
}https://serverfault.com/questions/964584
复制相似问题