Search code examples
terraformamazon-route53terraform-provider-aws

Terraform setting Route53 NS record never completes


resource "aws_route53_record" "fix-ns" {
  zone_id = aws_route53_zone.main.zone_id
  name    = var.domain_name
  type    = "NS"
  ttl     = "30"
  records = ["ns-1999.awsdns-57.co.uk", "ns-1031.awsdns-00.org", "ns-688.awsdns-22.net", "ns-325.awsdns-40.com"]
}

I want my Route53 NS record to match a known set of DNS NS records, so I've added the above resource. My automation IAM user has AmazonRoute53FullAccess. We get as far as aws_route53_record.fix-ns: Creating... ok, it throws no errors, but it never completes.

Suggestions as to why?

Edit: It's just occurred to me that I never see a Still creating... message for this resource, it just block further resource creations down the line.


Solution

  • I needed to add allow_overwrite = true to the resource.

    resource "aws_route53_record" "fix-ns" {
      allow_overwrite = true
      zone_id = aws_route53_zone.main.zone_id
      name    = var.domain_name
      type    = "NS"
      ttl     = "30"
      records = ["ns-1999.awsdns-57.co.uk", "ns-1031.awsdns-00.org", "ns-688.awsdns-22.net", "ns-325.awsdns-40.com"]
    }
    

    Weirdly I worked this out by doing a targeted deploy terraform apply -target=aws_route53_record.fix-ns. The resource was failing but the error did not surface in the full apply run, the targeted run allowed the error to surface. Which feels like a bug report :o