Skip to content

Serverless VPC access for Cloudrun across Projects

Firstly locate the Project numerical ID, this can be done via terraform using the below resource:


This will only work if you are creating the project through terraform, otherwise use the Data block


Create a network with a /28 subnet

resource "google_compute_subnetwork" "custom_test" {
  provider      = google-beta
  name          = "vpc-con"
  ip_cidr_range = ""
  project       =
  network       =

Now create the connection, and ensure you set the project field otherwise you will have issues

resource "google_vpc_access_connector" "connector" {
  provider = google-beta
  region   = "europe-west2"
  project  =
  name     = "vpc-conn-test-${random_integer.priority.result}"
  max_instances = 3
  min_instances = 2
  subnet {
    name =
    project_id =
  machine_type = "f1-micro" # (1)!

  1. Depending on how much network traffic you plan to send over this, the machine type needs to be larger. The default is e2-micro

You will need to give the vpc service account editor on the host

resource "google_project_iam_member" "project" {
  project =
  role    = "roles/editor"
  member  = "serviceAccount:${google_project.vpc-cloudrun.number}"

Want to make this site better? Open a PR or help fund hosting costs