1. Answers
  2. Deploying a GCP Service Networking Connection

How do I deploy a GCP service networking connection?

In this guide, we will deploy a service networking connection in Google Cloud Platform (GCP) using Pulumi. This connection allows your resources within a VPC network to securely access Google services like Google APIs, Cloud Storage, or BigQuery without using the public internet.

We will define a gcp.servicenetworking.Connection resource to establish this private connection.

Key Points

  • Network: Specify the VPC network to connect.
  • Service: The service for which the connection is being created (e.g., servicenetworking.googleapis.com).
  • Reserved Peering Ranges: Define the IP ranges reserved for the connection.

Below is the Pulumi program written in TypeScript to achieve this:

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

// Define the VPC network
const network = new gcp.compute.Network("my-vpc-network", {
    autoCreateSubnetworks: false,
});

// Reserve an IP range for the connection
const reservedPeeringRange = new gcp.compute.GlobalAddress("reserved-peering-range", {
    purpose: "VPC_PEERING",
    addressType: "INTERNAL",
    prefixLength: 16,
    network: network.id,
});

// Create the service networking connection
const serviceNetworkingConnection = new gcp.servicenetworking.Connection("service-networking-connection", {
    network: network.id,
    service: "servicenetworking.googleapis.com",
    reservedPeeringRanges: [reservedPeeringRange.name],
});

// Export the network name and reserved range URL
export const networkName = network.name;
export const reservedRangeUrl = reservedPeeringRange.selfLink;

Summary

In this guide, we deployed a service networking connection in GCP using Pulumi. We defined a VPC network, reserved an IP range for peering, and created the service networking connection to allow secure access to Google services. This setup helps in maintaining a private and secure communication channel within your VPC network.

Deploy this code

Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.

Sign up

New to Pulumi?

Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.

Sign up