amazon-web-servicesterraformterraform-provider-awsaws-route53

Amazon Route 53 Hosted Zone (`aws_route53_zone`) resource gets created with different Name Servers compared to Domain Name. How to handle this?


When I create Terraform resource aws_route53_zone it gets created with DNS Record NS that has different Name Servers compared to Domain Name.

I was curious, is there maybe some way using Terraform to add configuration, so that Hosted Zone would be created with same name servers as Domain Name has ?

Or should I manually create the Hosted Zone and then use data source aws_route53_zone to import it ?

What is the best practice here ?


Solution

  • When you create a hosted zone in Route 53, AWS automatically assigns it a set of name servers. These are not customizable at creation time, this is an AWS issue regardless of terraform. The mismatch occurs because AWS generates new name servers for each hosted zone. There’s no Terraform or AWS feature to predefine or match these name servers at creation time.

    so it's better to create the hosted zone in Terraform. AWS assigns new name servers, then you manually update the name. That will not cause any issue as changing the name servers at your domain registrar after creating the Route 53 Hosted Zone in Terraform does not cause Terraform’s state to drift.