» google_compute_network_peering

Manages a network peering within GCE. For more information see the official documentation and API.

» Example Usage

resource "google_compute_network_peering" "peering1" {
  name         = "peering1"
  network      = google_compute_network.default.self_link
  peer_network = google_compute_network.other.self_link
}

resource "google_compute_network_peering" "peering2" {
  name         = "peering2"
  network      = google_compute_network.other.self_link
  peer_network = google_compute_network.default.self_link
}

resource "google_compute_network" "default" {
  name                    = "foobar"
  auto_create_subnetworks = "false"
}

resource "google_compute_network" "other" {
  name                    = "other"
  auto_create_subnetworks = "false"
}

» Argument Reference

The following arguments are supported:

  • name - (Required) Name of the peering.

  • network - (Required) The primary network of the peering.

  • peer_network - (Required) The peer network in the peering. The peer network may belong to a different project.

  • export_custom_routes - (Optional) Whether to export the custom routes to the peer network. Defaults to false.

  • import_custom_routes - (Optional) Whether to export the custom routes from the peer network. Defaults to false.

» Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

  • state - State for the peering, either ACTIVE or INACTIVE. The peering is ACTIVE when there's a matching configuration in the peer network.

  • state_details - Details about the current state of the peering.

» Import

VPC network peerings can be imported using the name and project of the primary network the peering exists in and the name of the network peering

$ terraform import google_compute_network_peering.peering_network project-name/network-name/peering-name