首页 > 解决方案 > 如何在 Terraform 配置中使用共享 VPC GCP?

问题描述

我在 GCP 中配置了共享 VPC,我想知道如何在我的 terrafrom 中使用它。

在使用共享 VPC 之前,我的 terraform network_interface 部分如下:

network_interface {
    network     = "default"
    address     = "10.128.0.5"
    access_config {
      //nat_ip    = "xxx.xxx.xxx.xx"
    }
  }

我想知道是否有人可以指导我。

非常感谢。

谢谢!

-劳伦特

标签: terraformterraform-provider-gcp

解决方案


我没有尝试使用 terraform,但我很确定您可以按照示例使用共享 VPC:https ://github.com/terraform-providers/terraform-provider-google/tree/master/examples/shared-vpc

您的网络接口应如下所示:

network_interface {
  network = "${google_compute_network.shared_network.self_link}"
  access_config {
    nat_ip = "..."
  }
}

您需要使用固定的内部 IP(通过字段地址)还是可以使用自动受影响的地址?如果不能,则必须将地址图保存在某处,以确保不会影响已受影响的地址。

NAT IP 应该不会引起问题,但您知道...最好的答案是尝试一下;)


推荐阅读