使用GCP地形将域名附加到私有内部IP



嗨,我要为我的DNS区域创建一个DNS记录,这样我就可以通过主机名而不是IP地址将ssh设置为。我不能完全让terraform为我的用例创建域名。我怎样才能让它工作?我找不到正确的rrdata值。内部地址的IP是任意的,只要它在为VM指定的子网上即可。

resource "google_compute_instance" "tyler_test_vm_instance" {
count = var.node_count
name = "jenkins-worker-test-${count.index}"
machine_type = "n2-standard-2"
min_cpu_platform = "Intel Ice Lake"
attached_disk {
source = google_compute_disk.jenkins_data_disk.*.id[count.index]
device_name = "jenkins-data-test"
}
attached_disk {
source = google_compute_disk.docker_data_disk.*.id[count.index]
device_name = "docker-data-test"
}
lifecycle {
create_before_destroy = true
ignore_changes = [
attached_disk
]
}
service_account { 
email = "example@example.iam.gserviceaccount.com"
scopes = ["cloud-platform"]
}

boot_disk {
initialize_params {
image = "ubuntu-1804-bionic-v20220805"
}
}
network_interface {
network = var.gcp_project_network_name
subnetwork = var.subnet_name
}
metadata_startup_script = "${file(var.startup_script)}"
}

resource "google_dns_record_set" "rs" {
count = var.node_count
name = "jenkins-worker-test-${count.index}.com"
type = "A"
ttl = 300
managed_zone = "corp-org-com"
#no idea what goes in rrdatas. None of these work.
#rrdatas = ["jenkins-worker-test-${count.index}.com"]
rrdatas = [google_compute_instance.tyler_test_vm_instance.*.id[count.index].network_interface.network.network_ip]
#rrdatas = [google_compute_instance.tyler_test_vm_instance.*.id[count.index].network_interface[0]]
}

我有错误的rrdata,并且使用了错误的记录作为名称。

我应该用";詹金斯工人测试-${count.index}.corp.domain.com;这需要一个。最后。rrdata应该是这样的。rrdatas=[google_computer_instance.tyler_test_vm_instance.*[count.index].network_interface.0.network_ip]

一旦我改变了这些价值观,我就能让一切正常运转。

最新更新