Это рабочий пример в моем модуле экземпляра вычислений:
resource "google_compute_address" "internal" {
name = "${var.NAME}-int-ip"
subnetwork = "${var.SUBNETWORK}"
address_type = "INTERNAL"
address = "${var.PRIVATE_IP}"
region = "${var.REGION}"
}
resource "google_compute_address" "external" {
name = "${var.NAME}-ext-ip"
address_type = "EXTERNAL"
region = "${var.REGION}"
}
А затем в блоке ресурсов google_compute_instance установите IP-адрес в блоке network_infrastructure:
network_interface {
network= "${var.NETWORK}"
network_ip = "${google_compute_address.internal.address}"
access_config {
nat_ip = "${google_compute_address.external.address}"
}