Date 2023-01-26

Terraform: Error 400: Invalid value for 'entity.managedZone.dnsName'

※ この記事を書いてから1年以上経ってるかも

  tech ,  Terraform

エラー

GCP の Cloud DNS を Terraform から設定しようとしたところ、以下のエラーに遭遇。

Error creating ManagedZone: googleapi: Error 400: Invalid value for 'entity.managedZone.dnsName': 'example.com', invalid

そのときの tf ファイルは以下のような感じ。

resource "google_dns_managed_zone" "example-zone" {
  name        = "example-zone"
  dns_name    = "example.com"
  description = "Example DNS zone"
}

対応

dns_name の値の末尾に . が必要だった。

resource "google_dns_managed_zone" "example-zone" {
  name        = "example-zone"
  dns_name    = "example.com."
  description = "Example DNS zone"
}

これで解決!

参考