How to create route53 zone with predefined NS, or update NS of a registered domain?

bo-*_*-oz 5 amazon-web-services terraform terraform-provider-aws

I have a domain registered on Route 53. This domain points towards some name servers of an old Route53 route. I'm now building my Terraform script to create a new Route53 zone. Is it possible to set the name servers when creating this? I tried the following, but that didn't work:

resource "aws_route53_record" "dev-ns" {
  zone_id = "${aws_route53_zone.main.zone_id}"
  name    = "dev.example.com"
  type    = "NS"
  ttl     = "30"

  records = [
    "ns1.aws",
    "ns2.aws",
    "ns3.aws",
    "ns4.aws",
  ]
}
Run Code Online (Sandbox Code Playgroud)

I could imagine that this isn't possible, since the NS seem to assigned randomly. If this is indeed the case, is there a Terraform command to change the NS of my registered domain? I found this posting on Github, so I think there isn't any Terraform command for this: https://github.com/terraform-providers/terraform-provider-aws/issues/88

Any alternatives?

yda*_*coR 1

在您的情况下,您最好将现有的 Route53 区域导入到状态文件中,以便 Terraform 可以开始管理它,而不是创建一个使用相同名称服务器的新区域。

您可以使用以下命令导入区域:

terraform import aws_route53_zone.myzone Z1D633PJN98FT9
Run Code Online (Sandbox Code Playgroud)

其中import aws_route53_zone.myzone指资源名称和Z1D633PJN98FT9区域 ID。