Google 在 Digital Ocean 上使用 Terraform 验证 TXT 记录

Google TXT record verification with Terraform on Digital Ocean

我正在尝试验证我在我拥有的域下托管的网站。 Google告诉我

  1. Add the TXT record below to the DNS configuration for cescoferraro.xyz.

    google-site-verification=RANDOM_HASH

我在尝试什么:

resource "digitalocean_domain" "domain" {
  name = "cescoferraro.xyz"
  ip_address = "${digitalocean_droplet.master.ipv4_address}"
}

resource "digitalocean_record" "googleconfirmation" {
    domain = "${digitalocean_domain.domain.name}"
    type = "TXT"
    name = "google-site-verification"
    value = "RANDOM_HASH"
}

resource "digitalocean_record" "googleconfirmationnnn" {
    domain = "${digitalocean_domain.domain.name}"
    type = "TXT"
    name = "what"
    value = "google-site-verification=RANDOM_HASH"

}
resource "digitalocean_record" "googleconfirmationnssnn" {
    domain = "${digitalocean_domain.domain.name}"
    type = "TXT"
    name = "@"
    value = "google-site-verification=RANDOM_HASH"
}

我还不能验证我的域,可能是因为 DNS 缓存。我知道这需要一段时间,但正确的方法是什么?

根据我的经验,当您不尝试验证 www.domain.com 时,google 在验证说明中输入错误。 根据问题尝试验证域 mycoolhostname.domain.com 时,它明确告诉您:

  1. Add the TXT record below to the DNS configuration for domain.com.

什么时候应该说

  1. Add the TXT record below to the DNS configuration for mycoolhostname.domain.com.

按照@DusanBajic 的建议,terraform 代码应该是这样的:

resource "digitalocean_domain" "mycoolhostname" {
  name = "mycoolhostname.domain.com"
  ip_address = "${digitalocean_droplet.master.ipv4_address}"
}
resource "digitalocean_record" "google-mycoolhostname-confirmation" {
    domain = "${digitalocean_domain.mycoolhostname.name}"
    type = "TXT"
    name = "@"
    value = "google-site-verification=COOL_HASH"
}