【问题标题】:Provision a GCP VM instance with no external IP via Terraform通过 Terraform 配置没有外部 IP 的 GCP VM 实例
【发布时间】:2021-04-22 17:11:42
【问题描述】:

尝试通过 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

【问题讨论】:

    标签: google-cloud-platform terraform-provider-gcp


    【解决方案1】:

    要通过 terraform 在 GCP 中创建虚拟机没有外部 IP,您可以省略 network_interface 块中的 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"
    }
    

    【讨论】:

      猜你喜欢
      • 2019-08-12
      • 2022-01-18
      • 2020-04-02
      • 2021-09-26
      • 1970-01-01
      • 2021-09-20
      • 2021-10-19
      • 2020-09-05
      • 2021-06-27
      相关资源
      最近更新 更多