2

I have created a Zone In AWS Route53 as following

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}"
}

it will show out put as below

ns = [
    ns-754.awsdns-350.net,
    ns-555.awsdns-0553.org,
    ns-555.awsdns-25552.co.uk,
    ns-45569.awsdns-55555.com
]

Now i have question is how can i use this NS output as input in Cloudfalre like here

resource "cloudflare_record" "aws-ns-record" {
  domain = "${var.domain}"
  name   = "appgggghello.com"
  value = ["${data.aws_route53_zone.selected.name_servers}"]
  type     = "NS"
  priority = 1
}

Within Route53 i can set NS using

records = ["${data.aws_route53_zone.selected.name_servers}"]

Please let me know how can i achieve this ?

sanjayparmar
  • 633
  • 8
  • 19

1 Answers1

2

cloudflare_record takes a string for value not a list

value - (Optional) The (string) value of the record. Either this or data must be specified

So we need to add a count in there

Now i have question is how can i use this NS output as input in Cloudfalre like here. Then pull the element out of the list based on the count

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
}
Mike
  • 22,310
  • 7
  • 56
  • 79