Complete the code to create a Virtual Private Cloud (VPC) network in GCP.
resource "google_compute_network" "vpc_network" { name = "my-vpc-network" auto_create_subnetworks = [1] }
Setting auto_create_subnetworks to false creates a custom mode VPC, allowing advanced network control.
Complete the code to create a subnet in a specific region within the VPC.
resource "google_compute_subnetwork" "subnet" { name = "my-subnet" ip_cidr_range = "10.0.0.0/24" region = [1] network = google_compute_network.vpc_network.id }
The region must be a valid GCP region string like "us-central1" to place the subnet correctly.
Fix the error in the firewall rule to allow HTTP traffic on port 80.
resource "google_compute_firewall" "allow_http" { name = "allow-http" network = google_compute_network.vpc_network.id allow { protocol = [1] ports = ["80"] } direction = "INGRESS" source_ranges = ["0.0.0.0/0"] }
The protocol for HTTP traffic is tcp. Using "http" is invalid in this context.
Fill both blanks to configure a firewall rule that allows SSH access only from a specific IP range.
resource "google_compute_firewall" "allow_ssh" { name = "allow-ssh" network = google_compute_network.vpc_network.id allow { protocol = [1] ports = [[2]] } direction = "INGRESS" source_ranges = ["203.0.113.0/24"] }
SSH uses TCP protocol on port 22. The port must be a string inside the list.
Fill all three blanks to create a forwarding rule for HTTP traffic to a target proxy.
resource "google_compute_global_forwarding_rule" "http_forwarding_rule" { name = "http-forwarding-rule" load_balancing_scheme = [1] port_range = [2] target = [3] ip_protocol = "TCP" }
The forwarding rule uses an external load balancing scheme, listens on port 80, and targets the HTTP proxy resource.