Skip to content

Create a VPC network and subnet with Terraform on Google Cloud


  • Understand what VPC network is
  • Know to create a VPC network with Terraform on GCP


  • Google Cloud Account

What is VPC network?

A Virtual Private Cloud (VPC) is a virtual network dedicated to your Google Cloud Platform (GCP) project. It provides a way to organize and isolate resources within the GCP environment. With a VPC, you can define IP address ranges, create subnetworks, and configure routes.

You can create the subnetwork in default mode or custom mode.


provider "google" {

  project = "PROJECT ID"  #replace to your project id
  region  = "REGION"      #replace to your region
  zone    = "ZONE"        #replace to your zone

resource "google_compute_network" "vpc_network" {
  name                    = "instruction-415216-network"    # replace your unique resource name
  auto_create_subnetworks = false


resource "google_compute_subnetwork" "default" {
  name          = "instruction-415216-subnet"
  ip_cidr_range = ""
  region        = "us-west1"
  network       =