[英]Provision a GCP VM instance with no external IP via Terraform
Trying to create a VM in GCP via terraform with External IP as None.尝试通过 terraform 在 GCP 中创建 VM,外部 IP 为 None。
network_interface {
network = "projects/other-project-name/global/networks/network-name"
subnetwork = "projects/other-project-name/regions/us-central1/subnetworks/subnet-name"
access_config {
nat_ip = "None"
}
}
But nat_ip = "None"
is invalid value for the field.但是
nat_ip = "None"
是该字段的无效值。 And if I do nat_ip = ""
, it auto assigns External IP.如果我执行
nat_ip = ""
,它会自动分配外部 IP。
Here's their documentation: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance#nat_ip这是他们的文档: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance#nat_ip
To create a VM in GCP via terraform without External IP, you can just omit the access_config
section in network_interface
block, as documented here .要在没有外部 IP 的情况下通过 terraform 在 GCP 中创建 VM,您可以省略
network_interface
块中的access_config
部分,如此处所述。 So you'd have just:所以你只需要:
network_interface {
network = "projects/other-project-name/global/networks/network-name"
subnetwork = "projects/other-project-name/regions/us-central1/subnetworks/subnet-name"
}
Something has changed in the recent updates of the google provider and I couldn't resolve this problem until I've downgraded the network tier to standard, any other combination with network tier PREMIUM (default) or the omission of the block leads to VMs with ephemeral IPs谷歌提供商的最近更新发生了一些变化,直到我将网络层降级为标准,与网络层 PREMIUM(默认)的任何其他组合或块的省略导致 VM 与临时 IP
access_config {
nat_ip = ""
network_tier = "STANDARD"
}
I confirm the above behavior, as mentioned by LundinCast .如LundinCast所述,我确认上述行为。 In my case, I was not seeing the External IP configured for the VM I was creating using Terraform.
就我而言,我没有看到为我使用 Terraform 创建的 VM 配置的外部 IP。 I added the blank access_log block under network_interface section, and I got the external ip configured.
我在 network_interface 部分下添加了空白的 access_log 块,并配置了外部 ip。
network_interface {
network = "default"
access_config {
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.