Google Service Networking Connection

This page shows how to write Terraform for Service Networking Connection and write them securely.

google_service_networking_connection (Terraform)

The Connection in Service Networking can be configured in Terraform with the resource name google_service_networking_connection. The following sections describe 5 examples of how to use the resource and its parameters.

Example Usage from GitHub

networking.tf#L139
resource "google_service_networking_connection" "private_service_connections_production" {
  network                 = module.vpc_shared_networks_production.vpc.id
  service                 = "servicenetworking.googleapis.com"
  reserved_peering_ranges = [google_compute_global_address.private_service_connections_production.name]
}

main.tf#L39
resource "google_service_networking_connection" "private_vpc_conn_1" {
  provider = google-beta

  network                 = google_compute_network.private_network.id
  service                 = "servicenetworking.googleapis.com"
  reserved_peering_ranges = [google_compute_global_address.private_ip_1.name]
sql.tf#L70
resource "google_service_networking_connection" "private-vpc-db-connection" {
  network                 = google_compute_network.zone53.id
  service                 = "servicenetworking.googleapis.com"
  reserved_peering_ranges = [google_compute_global_address.sql-private-ip.name]
}

vpc-network.tf#L31
resource "google_service_networking_connection" "master-private-vpc-db-connection" {
  network                 = google_compute_network.vpc-network.id
  service                 = "servicenetworking.googleapis.com"
  reserved_peering_ranges = [google_compute_global_address.private-ip-address.name]
}
resource "google_service_networking_connection" "replica-private-vpc-db-connection" {
main.tf#L1
resource "google_service_networking_connection" "private_vpc_connection" {
  network       = var.network
  service       = "servicenetworking.googleapis.com"
  reserved_peering_ranges = var.reserved_peering_ranges

Review your Terraform file for Google best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

  • id optional computed - string
  • network required - string

Name of VPC network connected with service producers using VPC peering.

Named IP address range(s) of PEERING type reserved for this service provider. Note that invoking this method with a different range when connection is already established will not reallocate already provisioned service producer subnetworks.

Provider peering service that is managing peering connectivity for a service provider organization. For Google services that support this functionality it is 'servicenetworking.googleapis.com'.

Explanation in Terraform Registry

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

Frequently asked questions

What is Google Service Networking Connection?

Google Service Networking Connection is a resource for Service Networking of Google Cloud Platform. Settings can be wrote in Terraform.

Where can I find the example code for the Google Service Networking Connection?

For Terraform, the doitintl/terraform-gcp-templates, indeni/cloudrail-knowledge and Sahay-ohikc/Laboratory source code examples are useful. See the Terraform Example section for further details.

security-icon

Automate config file reviews on your commits

Fix issues in your infrastructure as code with auto-generated patches.