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 ?

1 Answer 1

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
}
4
  • i have tried but getting error Error: cloudflare_record.aws-ns-record: value must be a single value, not a list Commented May 3, 2019 at 13:18
  • sorry i left brackets around the value.. see the current answer for them removed and try that
    – Mike
    Commented May 4, 2019 at 19:05
  • Now its working Commented May 6, 2019 at 10:08
  • Now getting count error. its known issue. do you have any workaround? cloudflare_record.aws-ns-record: value of 'count' cannot be computed Commented May 6, 2019 at 14:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .