Complete the code to specify the network mode as custom when creating a VPC in GCP.
resource "google_compute_network" "custom_vpc" { name = "custom-vpc" auto_create_subnetworks = [1] }
Setting auto_create_subnetworks to false creates a custom mode VPC where you manually define subnets.
Complete the code to define a subnet with the correct IP range in the custom VPC.
resource "google_compute_subnetwork" "custom_subnet" { name = "custom-subnet" ip_cidr_range = "[1]" network = google_compute_network.custom_vpc.id region = "us-central1" }
The subnet IP range must be a valid CIDR block within private IP ranges. 10.0.0.0/16 is a common private range used for subnets.
Fix the error in the subnet resource by selecting the correct region value.
resource "google_compute_subnetwork" "custom_subnet" { name = "custom-subnet" ip_cidr_range = "10.0.1.0/24" network = google_compute_network.custom_vpc.id region = "[1]" }
The region field for a subnet must be a region name, not a zone or global. us-central1 is a valid region.
Fill both blanks to create a firewall rule allowing SSH access to the custom VPC.
resource "google_compute_firewall" "allow_ssh" { name = "allow-ssh" network = google_compute_network.custom_vpc.id allow { protocol = "[1]" ports = ["[2]"] } direction = "INGRESS" source_ranges = ["0.0.0.0/0"] }
SSH uses TCP protocol on port 22. The firewall rule must allow TCP on port 22 for SSH access.
Fill all three blanks to create a route in the custom VPC that directs traffic to the internet gateway.
resource "google_compute_route" "default_internet_route" { name = "default-internet-route" network = google_compute_network.custom_vpc.id dest_range = "[1]" next_hop_gateway = "[2]" priority = [3] }
The destination range 0.0.0.0/0 covers all IPs. The next hop gateway for internet access is default-internet-gateway. Priority is usually set to 1000 for custom routes.