Bird
Raised Fist0
GCPcloud~10 mins

Why VPC provides network isolation in GCP - Test Your Understanding

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a VPC network in GCP.

GCP
resource "google_compute_network" "vpc_network" {
  name = "my-vpc"
  auto_create_subnetworks = [1]
}
Drag options to blanks, or click blank then click option'
Afalse
Btrue
C"yes"
D"no"
Attempts:
3 left
💡 Hint
Common Mistakes
Using string values like "yes" or "no" instead of boolean true/false.
Setting auto_create_subnetworks to true creates default subnets, reducing isolation.
2fill in blank
medium

Complete the code to define a subnet within a VPC network.

GCP
resource "google_compute_subnetwork" "subnet" {
  name          = "my-subnet"
  ip_cidr_range = "10.0.0.0/24"
  network       = [1]
  region        = "us-central1"
}
Drag options to blanks, or click blank then click option'
Agoogle_compute_network.vpc_network.id
B"global"
C"default"
Dgoogle_compute_network.vpc_network.name
Attempts:
3 left
💡 Hint
Common Mistakes
Using just the network name string instead of the resource ID.
Using an incorrect region or global value for the network.
3fill in blank
hard

Fix the error in the firewall rule to allow internal traffic within the VPC.

GCP
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"]
}
Drag options to blanks, or click blank then click option'
A"udp"
B"icmp"
C"all"
D"tcp"
Attempts:
3 left
💡 Hint
Common Mistakes
Using only tcp or udp limits allowed traffic.
Using icmp only allows ping, not all internal traffic.
4fill in blank
hard

Fill both blanks to define a route that directs traffic to the internet gateway.

GCP
resource "google_compute_route" "default_internet_route" {
  name       = "default-internet-route"
  network    = [1]
  dest_range = [2]
  next_hop_internet = true
}
Drag options to blanks, or click blank then click option'
Agoogle_compute_network.vpc_network.id
B"0.0.0.0/0"
C"10.0.0.0/24"
Dgoogle_compute_subnetwork.subnet.name
Attempts:
3 left
💡 Hint
Common Mistakes
Using subnet name instead of network ID.
Using a subnet CIDR block instead of 0.0.0.0/0 for internet traffic.
5fill in blank
hard

Fill all three blanks to create a VPC peering connection between two networks.

GCP
resource "google_compute_network_peering" "peer" {
  name         = [1]
  network      = [2]
  peer_network = [3]
  auto_create_routes = true
}
Drag options to blanks, or click blank then click option'
A"peer-connection-1"
Bgoogle_compute_network.vpc_network.id
Cgoogle_compute_network.peer_vpc.id
D"peer-connection-2"
Attempts:
3 left
💡 Hint
Common Mistakes
Using peer connection names as network IDs.
Mixing up network and peer_network values.

Practice

(1/5)
1. What is the main reason a VPC provides network isolation in GCP?
easy
A. It allows unlimited public internet access.
B. It automatically encrypts all data in the cloud.
C. It shares IP addresses with other VPCs.
D. It creates a private network space separate from other users.

Solution

  1. Step 1: Understand what a VPC is

    A VPC (Virtual Private Cloud) is a private network space in the cloud that you control.
  2. Step 2: Identify how isolation is achieved

    Because the VPC is private, it separates your resources from others, preventing unwanted access.
  3. Final Answer:

    It creates a private network space separate from other users. -> Option D
  4. Quick Check:

    Private network space = Isolation [OK]
Hint: VPC means private network space, so it isolates [OK]
Common Mistakes:
  • Thinking VPC automatically encrypts all data
  • Assuming VPC allows open internet access
  • Believing IP addresses are shared across VPCs
2. Which of the following is the correct way to define a subnet inside a VPC in GCP?
easy
A. subnets: [{name: 'subnet-1', cidr: '10.0.0.0/24'}]
B. subnetworks: [{name: 'subnet-1', ipRange: '10.0.0.0/24'}]
C. subnetworks: [{name: 'subnet-1', ipCidrRange: '10.0.0.0/24'}]
D. networks: [{subnet: 'subnet-1', range: '10.0.0.0/24'}]

Solution

  1. Step 1: Recall GCP subnet syntax

    In GCP, subnets are defined with 'subnetworks' and use 'ipCidrRange' for the IP range.
  2. Step 2: Match correct keys

    subnetworks: [{name: 'subnet-1', ipCidrRange: '10.0.0.0/24'}] uses 'subnetworks' and 'ipCidrRange', which is correct syntax.
  3. Final Answer:

    subnetworks: [{name: 'subnet-1', ipCidrRange: '10.0.0.0/24'}] -> Option C
  4. Quick Check:

    Correct keys = subnetworks: [{name: 'subnet-1', ipCidrRange: '10.0.0.0/24'}] [OK]
Hint: Look for 'ipCidrRange' key in subnet definition [OK]
Common Mistakes:
  • Using 'ipRange' instead of 'ipCidrRange'
  • Using 'subnets' instead of 'subnetworks'
  • Mixing 'networks' and 'subnet' keys incorrectly
3. Given two VPCs with no peering, what happens if a VM in VPC A tries to ping a VM in VPC B?
medium
A. The ping fails because VPCs are isolated by default.
B. The ping fails unless firewall rules allow it.
C. The ping succeeds only if both VMs have public IPs.
D. The ping succeeds because all VPCs share the same network.

Solution

  1. Step 1: Understand default VPC isolation

    By default, VPCs are isolated and cannot communicate without peering or VPN.
  2. Step 2: Analyze ping behavior

    Since no peering exists, ping from VPC A to VPC B fails regardless of firewall rules.
  3. Final Answer:

    The ping fails because VPCs are isolated by default. -> Option A
  4. Quick Check:

    Default isolation blocks ping = The ping fails because VPCs are isolated by default. [OK]
Hint: No peering means no communication between VPCs [OK]
Common Mistakes:
  • Assuming all VPCs share network by default
  • Thinking firewall rules alone enable cross-VPC ping
  • Believing public IPs allow ping without routing
4. You created two subnets in the same VPC but cannot connect VMs between them. What is the most likely cause?
medium
A. Firewall rules block traffic between the subnets.
B. Subnets must be in different VPCs to communicate.
C. VPCs do not allow communication between subnets.
D. VMs need public IPs to connect inside a VPC.

Solution

  1. Step 1: Recall subnet communication in a VPC

    Subnets in the same VPC can communicate by default unless blocked.
  2. Step 2: Identify cause of blocked communication

    Firewall rules can block traffic between subnets even inside the same VPC.
  3. Final Answer:

    Firewall rules block traffic between the subnets. -> Option A
  4. Quick Check:

    Firewall blocks = no subnet communication [OK]
Hint: Check firewall rules first when subnets can't connect [OK]
Common Mistakes:
  • Thinking subnets in same VPC can't communicate
  • Assuming VMs need public IPs for internal traffic
  • Believing subnets must be in different VPCs
5. You want to isolate two teams' resources in the same GCP project. Which approach best uses VPC features to provide network isolation?
hard
A. Use one VPC with shared subnets and rely on firewall rules only.
B. Create two separate VPCs, one for each team, with no peering.
C. Assign public IPs to all VMs and use external firewalls.
D. Create one VPC and connect all resources with default routes.

Solution

  1. Step 1: Understand isolation needs

    To isolate teams, separate network spaces are best to avoid accidental access.
  2. Step 2: Evaluate VPC options

    Creating separate VPCs with no peering ensures strong isolation by default.
  3. Final Answer:

    Create two separate VPCs, one for each team, with no peering. -> Option B
  4. Quick Check:

    Separate VPCs = best isolation [OK]
Hint: Separate VPCs isolate teams best, avoid shared subnets [OK]
Common Mistakes:
  • Relying only on firewall rules inside one VPC
  • Using public IPs for internal isolation
  • Connecting all resources in one VPC without restrictions