google_service_networking_connection

Manages a private VPC connection with a GCP service provider. For more information see the official documentation and API.

Example usage

# Create a VPC network
resource "google_compute_network" "peering_network" {
  name = "peering-network"
}

# Create an IP address
resource "google_compute_global_address" "private_ip_alloc" {
  name          = "private-ip-alloc"
  purpose       = "VPC_PEERING"
  address_type  = "INTERNAL"
  prefix_length = 16
  network       = google_compute_network.peering_network.id
}

# Create a private connection
resource "google_service_networking_connection" "default" {
  network                 = google_compute_network.peering_network.id
  service                 = "servicenetworking.googleapis.com"
  reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name]
}

# (Optional) Import or export custom routes
resource "google_compute_network_peering_routes_config" "peering_routes" {
  peering = google_service_networking_connection.default.peering
  network = google_compute_network.peering_network.name

  import_custom_routes = true
  export_custom_routes = true
}

Argument Reference

The following arguments are supported:

Attributes Reference

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

Import

ServiceNetworkingConnection can be imported using any of these accepted formats

In Terraform v1.5.0 and later, use an import block to import NAME_HERE using one of the formats above. For example:

import {
  id = "projects/{{project}}/global/networks/{{peering-network}}:{{service}}"
  to = google_service_networking_connection.default
}

When using the terraform import command, NAME_HERE can be imported using one of the formats above. For example:

$ terraform import google_service_networking_connection.default {{peering-network}}:{{service}}
$ terraform import google_service_networking_connection.default /projects/{{project}}/global/networks/{{peering-network}}:{{service}}

User Project Overrides

This resource supports User Project Overrides.