【问题标题】:How to use Terraform to create a wildcard dns record in an Amazon VPC to point to a service discovery server?如何使用 Terraform 在 Amazon VPC 中创建通配符 dns 记录以指向服务发现服务器?
【发布时间】:2016-09-09 17:00:36
【问题描述】:

我有一个带有堡垒和服务发现路由器 (Consul) 的 Amazon VPC,用于将流量从公司的 Intranet 路由到 VPC。

现在我正在 VPC (Webdriver) 中运行需要从 docker swarm host 查找新注册服务的作业。

我想从 VPC 指向服务发现服务器。

我想使用Terraform 创建这个dns wildcard entry

这是我第一次尝试 - 但我觉得缺少一些东西:

resource "aws_route53_record" "*" {
   zone_id = "${myzone.primary.zone_id}"
   name = "*.cloud.companyintranet.com"
   type = "A"
   ttl = "300"
   records = ["${aws_eip.lb.public_ip}"]
}

我的问题是:如何使用 Terraform 在 Amazon VPC 中创建通配符 dns 记录以指向服务发现服务器?

【问题讨论】:

  • 这有什么问题?它不工作吗?我不确定是否使用 * 作为资源使用名称,因为我想这可能会导致 Terraform 对循环中创建的事物的 splats 出现一些问题,而且名称 wildcard 似乎更易于解释。
  • 资源部分resource "aws_route53_record" "*" 有误,不能在terraform中使用*作为资源名称

标签: amazon-web-services dns routing wildcard-subdomain terraform


【解决方案1】:

* 绝对适用于通配符,但仅适用于 NAME 字段:

resource "aws_route53_record" "wildcard_cloud_companyintranet_com" {
   zone_id = "${myzone.primary.zone_id}"
   name = "*.cloud.companyintranet.com"
   type = "A"
   ttl = "300"
   records = ["${aws_eip.lb.public_ip}"]
}

只需确保在资源字段中使用描述性名称,而不是 *

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-23
    • 1970-01-01
    • 2012-01-20
    • 1970-01-01
    相关资源
    最近更新 更多