Facing issue during VPC creation in GCP

I’m getting an issue when trying to create gcp vpc using terraform module registry in google cloud. Below is my code with error details , please help. [root@test VPC]# terraform plan

│ Error: Missing required argument

│ on main.tf line 17, in module “vpc”:
│ 17: module “vpc” {

│ The argument “subnets” is required, but no definition was found.

[root@test VPC]# more main.tf
terraform {
required_providers {
google = {
source = “hashicorp/google”
version = “4.61.0”
}
}
}

provider “google” {
credentials = file(“keys.json”)
project = “terraform-384408”
region = “us-west1”
zone = “us-west1-a”
}

module “vpc” {
source = “terraform-google-modules/network/google”
version = “7.0.0”

insert the 3 required variables here

network_name = var.network_name
auto_create_subnetworks = var.auto_create_subnetworks
routing_mode = var.routing_mode
project_id = var.project_id
description = var.description
delete_default_internet_gateway_routes = var.delete_default_internet_gateway_routes
mtu = var.mtu
}

[root@test VPC]#

I have seperate terraform.tfvars file. However, I want to highlight that, when I’m using resource instead of module, it’s working fine by using the same argument with same values.

You need to provide the list of subnets you want to create:

See an example here

Hi @ddsanjoy ,

Please do note that Terraform literally told you what the problem was automatically:

You did not specify something that was required, so Terraform told you what (subnets) and where (that module block).