Aws_route53_record NS record documented example

In the documentation for aws_route53_record, the example used is:

resource "aws_route53_zone" "example" {
  name = "test.example.com"
}

resource "aws_route53_record" "example" {
  allow_overwrite = true
  name            = "test.example.com"
  ttl             = 30
  type            = "NS"
  zone_id         = "${aws_route53_zone.example.zone_id}"

  records = [
    "${aws_route53_zone.example.name_servers.0}",
    "${aws_route53_zone.example.name_servers.1}",
    "${aws_route53_zone.example.name_servers.2}",
    "${aws_route53_zone.example.name_servers.3}",
  ]
}

I’m curious if and why there is a need to be so verbose as opposed to something like:

resource "aws_route53_record" "example" {
  allow_overwrite = true
  name            = "test.example.com"
  ttl             = 30
  type            = "NS"
  zone_id         = aws_route53_zone.example.zone_id

  records = aws_route53_zone.example.name_servers
}

TIA

Hi @yruss972,

I think the example you’ve seen here is written to be compatible with both Terraform 0.11 and 0.12, and Terraform 0.11’s language runtime had a design flaw where an expression like you’ve shown in your second example would produce an incorrect error “a list is required”. (That was one of the things that the new language runtime in Terraform 0.12 addressed.)

You’re correct that the direct reference to the list should be sufficient for Terraform 0.12. The provider development teams are currently still maintaining most documentation in a form that is compatible with Terraform 0.11 and 0.12 where possible; simplifications like the one you shared are likely to happen only once provider support for Terraform 0.11 is phased out, as a measure of pragmatism.

1 Like