gpt4 book ai didi

google-cloud-platform - 通过 Terraform 配置没有外部 IP 的 GCP VM 实例

转载 作者:行者123 更新时间:2023-12-05 01:32:05 25 4
gpt4 key购买 nike

尝试通过 Terraform 在 GCP 中创建虚拟机,外部 IP 为无。

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"
}
}

但是 nat_ip = "None" 是该字段的无效值。如果我执行 nat_ip = "",它会自动分配外部 IP。
这是他们的文档:https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance#nat_ip

最佳答案

要通过 Terraform 在 GCP 中创建虚拟机没有外部 IP,您可以省略 network_interface block 中的 access_config 部分,如 here 所述.所以你只需:

network_interface {
network = "projects/other-project-name/global/networks/network-name"
subnetwork = "projects/other-project-name/regions/us-central1/subnetworks/subnet-name"
}

关于google-cloud-platform - 通过 Terraform 配置没有外部 IP 的 GCP VM 实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65773940/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com