当terrafrorm使用aws_route53_zone时,如何指定dns服务器

时间:2017-06-17 21:00:39

标签: amazon-web-services dns terraform

当terraform运行以下内容时,它显然会选择随机的NS服务器:

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

这个问题是我在AWS中注册的域已经指定了NS服务器。有没有办法指定此资源使用的NS服务器 - 或者可能将托管域的NS服务器更改为创建区域时选择的内容?

2 个答案:

答案 0 :(得分:0)

创建新区域时,AWS会为您生成名称服务器列表。使用Terraform的这个例子。

resource "aws_route53_zone" "dev" {
  name = "dev.example.com"

  tags {
    Environment = "dev"
  }
}

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

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

https://www.terraform.io/docs/providers/aws/r/route53_zone.html

API在调用Create Zone后返回一个委托集。

http://docs.aws.amazon.com/Route53/latest/APIReference/API_CreateHostedZone.html#API_CreateHostedZone_ResponseSyntax

答案 1 :(得分:0)

我已经能够指定DNS服务器了,但我认为AWS正在根据可用性,负载等分配服务器......所以你可能想要仔细考虑烘焙这些配置。

resource "aws_route53_record" "primary-ns" {
  zone_id = "${aws_route53_zone.primary.zone_id}"
  name    = "www.bacon.rocks"
  type = "NS"
  ttl = "172800"
  records = ["ns-869.awsdns-44.net","ns-1237.awsdns-26.org","ns-1846.awsdns-38.co.uk","ns-325.awsdns-40.com"]
}

或沿着这些方向的东西