https://www.terraform.io/docs/providers/google/r/compute_instance.html
我想保留一个外部和内部IP,但是我如何同时附加两个?我没有在tf文档中看到示例。
它只有network_ip - (Optional) The *private* IP address ...
https://www.terraform.io/docs/providers/google/r/compute_instance.html#network_interface
答案 0 :(得分:2)
这是我的计算实例模块中的一个有效示例:
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资源块中,在network_infrastructure块中设置IP:
network_interface {
network= "${var.NETWORK}"
network_ip = "${google_compute_address.internal.address}"
access_config {
nat_ip = "${google_compute_address.external.address}"
}