0
0
GCPcloud~10 mins

Custom VPC creation in GCP - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the network mode as custom when creating a VPC in GCP.

GCP
resource "google_compute_network" "custom_vpc" {
  name                    = "custom-vpc"
  auto_create_subnetworks = [1]
}
Drag options to blanks, or click blank then click option'
Afalse
Bnull
C"custom"
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Setting auto_create_subnetworks to true creates an automatic VPC, not custom.
Using string values like "custom" instead of boolean false.
2fill in blank
medium

Complete the code to define a subnet with the correct IP range in the custom VPC.

GCP
resource "google_compute_subnetwork" "custom_subnet" {
  name          = "custom-subnet"
  ip_cidr_range = "[1]"
  network       = google_compute_network.custom_vpc.id
  region        = "us-central1"
}
Drag options to blanks, or click blank then click option'
A10.0.0.0/16
B192.168.1.0/24
C172.16.0.0/12
D0.0.0.0/0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0.0.0.0/0 which is invalid for subnet IP range.
Using public IP ranges instead of private ones.
3fill in blank
hard

Fix the error in the subnet resource by selecting the correct region value.

GCP
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]"
}
Drag options to blanks, or click blank then click option'
Aus-central1-a
Bus-west1-b
Cglobal
Dus-central1
Attempts:
3 left
💡 Hint
Common Mistakes
Using zone names like 'us-central1-a' instead of region names.
Using 'global' which is invalid for subnet region.
4fill in blank
hard

Fill both blanks to create a firewall rule allowing SSH access to the custom VPC.

GCP
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"]
}
Drag options to blanks, or click blank then click option'
Atcp
B22
Cudp
D80
Attempts:
3 left
💡 Hint
Common Mistakes
Using UDP protocol which SSH does not use.
Using port 80 which is for HTTP, not SSH.
5fill in blank
hard

Fill all three blanks to create a route in the custom VPC that directs traffic to the internet gateway.

GCP
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]
}
Drag options to blanks, or click blank then click option'
A0.0.0.0/0
Bdefault-internet-gateway
C1000
Ddefault-gateway
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect next hop gateway names.
Setting priority too low or using invalid values.