0
0
GCPcloud~30 mins

Default VPC and subnets in GCP - Mini Project: Build & Apply

Choose your learning style9 modes available
Default VPC and Subnets Setup in GCP
📖 Scenario: You are setting up a Google Cloud Platform (GCP) project. You want to create a default Virtual Private Cloud (VPC) network with its default subnets in each region. This setup allows your cloud resources to communicate securely within the network.
🎯 Goal: Create a default VPC network named default and add default subnets for the regions us-central1, us-east1, and europe-west1. Each subnet should have the correct IP range as per GCP defaults.
📋 What You'll Learn
Create a dictionary called default_vpc with the key name set to default
Create a list called regions containing 'us-central1', 'us-east1', and 'europe-west1'
Create a dictionary called subnet_ip_ranges mapping each region to its default subnet IP range
Create a list called subnets that contains dictionaries for each subnet with keys name, region, and ip_cidr_range
Add the subnets list as a key in the default_vpc dictionary
💡 Why This Matters
🌍 Real World
Setting up a default VPC with subnets is a common first step in organizing cloud resources securely and efficiently in GCP.
💼 Career
Cloud engineers and architects often need to configure networks and subnets to ensure proper resource communication and security.
Progress0 / 4 steps
1
Create the default VPC dictionary
Create a dictionary called default_vpc with a key name set to the string 'default'.
GCP
Need a hint?

Use curly braces {} to create a dictionary and set the key "name" to "default".

2
Create the regions list and subnet IP ranges dictionary
Create a list called regions containing the strings 'us-central1', 'us-east1', and 'europe-west1'. Then create a dictionary called subnet_ip_ranges mapping 'us-central1' to '10.128.0.0/20', 'us-east1' to '10.142.0.0/20', and 'europe-west1' to '10.132.0.0/20'.
GCP
Need a hint?

Use square brackets [] for the list and curly braces {} for the dictionary. Match the exact strings and IP ranges.

3
Create the subnets list with dictionaries for each region
Create a list called subnets that contains a dictionary for each region in regions. Each dictionary should have keys: name set to "default-" plus the region name, region set to the region name, and ip_cidr_range set to the corresponding value from subnet_ip_ranges. Use a for loop with variables region to build this list.
GCP
Need a hint?

Use a for loop to iterate over regions. For each region, create a dictionary with the required keys and append it to subnets.

4
Add the subnets list to the default VPC dictionary
Add the subnets list as a key named subnets inside the default_vpc dictionary.
GCP
Need a hint?

Assign the subnets list to the key "subnets" in the default_vpc dictionary.