Complete the code to create a VPC network in GCP.
resource "google_compute_network" "vpc_network" { name = "my-vpc" auto_create_subnetworks = [1] }
Setting auto_create_subnetworks to false creates a custom mode VPC, which allows network isolation by controlling subnet creation.
Complete the code to define a subnet within a VPC network.
resource "google_compute_subnetwork" "subnet" { name = "my-subnet" ip_cidr_range = "10.0.0.0/24" network = [1] region = "us-central1" }
The network field requires the network's self link or ID to associate the subnet with the VPC.
Fix the error in the firewall rule to allow internal traffic within the VPC.
resource "google_compute_firewall" "internal_allow" { name = "allow-internal" network = google_compute_network.vpc_network.id allow { protocol = [1] ports = ["0-65535"] } source_ranges = ["10.0.0.0/8"] }
Using "all" as the protocol allows all traffic types within the VPC, enabling full internal communication.
Fill both blanks to define a route that directs traffic to the internet gateway.
resource "google_compute_route" "default_internet_route" { name = "default-internet-route" network = [1] dest_range = [2] next_hop_internet = true }
The route must be associated with the VPC network ID and use 0.0.0.0/0 as the destination range to route all internet traffic.
Fill all three blanks to create a VPC peering connection between two networks.
resource "google_compute_network_peering" "peer" { name = [1] network = [2] peer_network = [3] auto_create_routes = true }
The peering resource needs a unique name, the local VPC network ID, and the peer VPC network ID to establish the connection.