GSP213
Overview
In the real world, you need to protect sensitive data and ensure the continued availability of your web applications at all times. In this lab, you learn how to use Google Cloud VPC networking to create a secure, scalable, and manageable web server deployment.
You will create two nginx web servers on the default VPC network and control external HTTP access using tagged firewall rules. Then, you will explore IAM roles and service accounts to understand least-privilege administrative access for networking and security roles.
- Two web servers provide redundancy—if one server fails, the other can continue serving web traffic.
- Tagged firewall rules provide granular control over which traffic is allowed to reach specific web servers.
- By assigning a service account specific permissions, you uphold the principle of least privilege, keeping your Cloud resources safe.
Objectives
In this lab, you learn how to perform the following tasks:
- Create nginx web servers on a VPC network with network tags and startup scripts.
- Create tagged firewall rules to control external HTTP access.
- Grant IAM roles to a service account.
- Explore permissions for the Network Admin and Security Admin roles.
Setup and requirements
Before you click the Start Lab button
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.
This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
- Access to a standard internet browser (Chrome browser recommended).
Note: Use an Incognito (recommended) or private browser window to run this lab. This prevents conflicts between your personal account and the student account, which may cause extra charges incurred to your personal account.
- Time to complete the lab—remember, once you start, you cannot pause a lab.
Note: Use only the student account for this lab. If you use a different Google Cloud account, you may incur charges to that account.
How to start your lab and sign in to the Google Cloud console
-
Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method.
On the right is the Lab setup and access panel with the following:
- The Open Google Cloud console button
- The temporary credentials (username and password) that you must use for this lab
- Other information, if needed, to step through this lab
Note that the lab timer is located near the top of the page, showing the remaining time.
-
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
Note: If you see the Choose an account dialog, click Use Another Account.
-
If necessary, copy the Username below and paste it into the Sign in dialog.
{{{user_0.username | "Username"}}}
You can also find the Username in the Lab setup and access panel.
-
Click Next.
-
Copy the Password below and paste it into the Welcome dialog.
{{{user_0.password | "Password"}}}
You can also find the Password in the Lab setup and access panel.
-
Click Next.
Important: You must use the credentials the lab provides you. Do not use your Google Cloud account credentials.
Note: Using your own Google Cloud account for this lab may incur extra charges.
-
Click through the subsequent pages:
- Accept the terms and conditions.
- Do not add recovery options or two-factor authentication (because this is a temporary account).
- Do not sign up for free trials.
After a few moments, the Google Cloud console opens in this tab.
Note: To access Google Cloud products and services, click the Navigation menu or type the service or product name in the Search field.
Activate Cloud Shell
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
-
Click Activate Cloud Shell
at the top of the Google Cloud console.
-
Click through the following windows:
- Continue through the Cloud Shell information window.
- Authorize Cloud Shell to use your credentials to make Google Cloud API calls.
When you are connected, you are already authenticated, and the project is set to your Project_ID, . The output contains a line that declares the Project_ID for this session:
Your Cloud Platform project in this session is set to {{{project_0.project_id | "PROJECT_ID"}}}
gcloud is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
- (Optional) You can list the active account name with this command:
gcloud auth list
- Click Authorize.
Output:
ACTIVE: *
ACCOUNT: {{{user_0.username | "ACCOUNT"}}}
To set the active account, run:
$ gcloud config set account `ACCOUNT`
- (Optional) You can list the project ID with this command:
gcloud config list project
Output:
[core]
project = {{{project_0.project_id | "PROJECT_ID"}}}
Note: For full documentation of gcloud, in Google Cloud, refer to the gcloud CLI overview guide.
Task 1. Create the web servers
In this section, you create two web servers (blue and green) in the default VPC network. You will use automated startup scripts to install nginx and customize the welcome page on each server, applying a network tag to the blue server.
Create the blue server
Create the blue server with the web-server network tag.
-
In the Google Cloud console, on the Navigation menu (
), select Compute Engine > VM instances.
-
Click Create instance.
-
In Machine configuration, specify the following:
| Property |
Value |
| Name |
blue |
| Region |
|
| Zone |
|
| Boot disk |
(default) |
-
Scroll down to the bottom of the page and expand Advanced options.
-
Click the Networking tab. For Network tags, type web-server
-
Click the Management tab, scroll down to Automation / Startup script, and paste the following script:
#!/bin/bash
apt-get update
apt-get install -y nginx-light
echo "<h1>Welcome to the blue server!</h1>" > /var/www/html/index.nginx-debian.html
- Click Create.
Test Completed Task
Click Check my progress to verify your performed task.
Create the blue server.
Create the green server
Create the green server without a network tag.
-
On the VM instances page, click Create instance.
-
In Machine configuration, specify the following:
| Property |
Value |
| Name |
green |
| Region |
|
| Zone |
|
| Boot disk |
(default) |
-
Scroll down and expand Advanced options.
-
Click the Management tab, scroll down to Automation / Startup script, and paste the following script:
#!/bin/bash
apt-get update
apt-get install -y nginx-light
echo "<h1>Welcome to the green server!</h1>" > /var/www/html/index.nginx-debian.html
Note: Do not add any network tags to the green server. The green server serves as an untagged control instance to demonstrate tagged firewall filtering.
- Click Create.
Test Completed Task
Click Check my progress to verify your performed task.
Create the green server.
Verify nginx installation
The startup scripts automatically install Nginx and write the custom HTML welcome pages as each instance boots.
Test Completed Task
Click Check my progress to verify your performed task.
Install Nginx and customize the welcome page.
Task 2. Create the firewall rule and test HTTP connectivity
Create a tagged firewall rule to allow external HTTP traffic only to VM instances tagged with web-server.
Create the tagged firewall rule
-
In the Google Cloud console, on the Navigation menu (
), select VPC network > Firewall.
-
Notice the pre-existing default-allow-internal firewall rule, which permits internal communication across all instances in the default VPC.
-
Click Create firewall rule and configure the following settings:
| Property |
Value |
| Name |
allow-http-web-server |
| Network |
default |
| Targets |
Specified target tags |
| Target tags |
web-server |
| Source filter |
IPv4 Ranges |
| Source IPv4 ranges |
0.0.0.0/0 |
| Protocols and ports |
Check tcp, type 80; check Other protocols, type icmp
|
-
Click Create.
Test Completed Task
Click Check my progress to verify your performed task.
Create the tagged firewall rule.
Create a test-vm
Create a test-vm instance from Cloud Shell to test internal VPC reachability.
-
Open Cloud Shell.
-
Run the following command to create the test-vm instance in the zone:
gcloud compute instances create test-vm --machine-type=e2-micro --subnet=default --zone={{{project_0.default_zone|ZONE}}}
Test Completed Task
Click Check my progress to verify your performed task.
Create a test-vm.
Test HTTP connectivity
In Cloud Shell, inspect the internal and external IP addresses of your instances and test network connectivity.
- In Cloud Shell, export the external and internal IP addresses as variables:
export ZONE={{{project_0.default_zone|ZONE}}}
export BLUE_EXTERNAL_IP=$(gcloud compute instances describe blue --zone=$ZONE --format='get(networkInterfaces[0].accessConfigs[0].natIP)')
export GREEN_EXTERNAL_IP=$(gcloud compute instances describe green --zone=$ZONE --format='get(networkInterfaces[0].accessConfigs[0].natIP)')
export BLUE_INTERNAL_IP=$(gcloud compute instances describe blue --zone=$ZONE --format='get(networkInterfaces[0].networkIP)')
export GREEN_INTERNAL_IP=$(gcloud compute instances describe green --zone=$ZONE --format='get(networkInterfaces[0].networkIP)')
- Test external HTTP connectivity to the blue server from Cloud Shell:
curl -m 3 http://$BLUE_EXTERNAL_IP
You should see the output:
<h1>Welcome to the blue server!</h1>
- Test external HTTP connectivity to the green server from Cloud Shell:
curl -m 3 http://$GREEN_EXTERNAL_IP
Note: This request should time out! The allow-http-web-server firewall rule only targets instances with the web-server tag. Because green has no tag, external HTTP access is blocked.
- Test internal HTTP connectivity from inside the VPC by executing
curl from test-vm:
gcloud compute ssh test-vm --zone=$ZONE --command="curl -s http://$BLUE_INTERNAL_IP"
gcloud compute ssh test-vm --zone=$ZONE --command="curl -s http://$GREEN_INTERNAL_IP"
Note: Both requests succeed and return welcome headers when run from inside the VPC network, because the default-allow-internal firewall rule permits internal traffic between all instances in the default network.
Task 3. Explore the Network and Security Admin roles
Cloud IAM lets you authorize who can take action on specific resources. In this section, you explore the differences between two core networking roles:
-
Network Admin (
roles/compute.networkAdmin): Permissions to create, modify, and delete networking resources, except for firewall rules and SSL certificates.
-
Security Admin (
roles/compute.securityAdmin): Permissions to create, modify, and delete firewall rules and SSL certificates.
Grant the Network Admin role to the service account
A service account named network-admin has been pre-created for this lab. Grant it the Compute Network Admin role.
- In the Google Cloud console, on the Navigation menu (
), select IAM & Admin > Service Accounts, and confirm that the pre-created network-admin service account exists:
network-admin@{{{project_0.project_id|PROJECT_ID}}}.iam.gserviceaccount.com
-
In the navigation pane, click IAM, and then click Grant access.
-
For New principals, paste the network-admin service account email address shown in step 1.
-
For Select a role, select Compute Engine > Compute Network Admin, and then click Save.
Test Completed Task
Click Check my progress to verify your performed task.
Create a Network-admin service account.
Authorize credentials and verify Network Admin permissions
- In Cloud Shell, create and download a key for the
network-admin service account:
gcloud iam service-accounts keys create $HOME/credentials.json \
--iam-account=network-admin@{{{project_0.project_id|PROJECT_ID}}}.iam.gserviceaccount.com
- Activate the service account credentials in Cloud Shell:
gcloud auth activate-service-account --key-file=$HOME/credentials.json
Security Best Practice Note: Downloading service account keys to local files creates persistent credentials that require manual rotation and increase security risk. In production Google Cloud environments, prefer short-lived credentials via service account impersonation (gcloud --impersonate-service-account) or Workload Identity Federation instead of downloading persistent JSON keys. For more information, see Best practices for managing service account keys.
- Try to list the available firewall rules:
gcloud compute firewall-rules list
This succeeds because the Network Admin role grants compute.firewalls.list.
- Try to delete the allow-http-web-server firewall rule:
gcloud compute firewall-rules delete allow-http-web-server --quiet
The output should show:
ERROR: (gcloud.compute.firewall-rules.delete) Could not fetch resource:
- Required 'compute.firewall.delete' permission for 'projects/.../global/firewalls/allow-http-web-server'
Note: As expected, the Network Admin role has permissions to list firewall rules, but lacks permission to modify or delete them.
Update service account to Security Admin and verify permissions
-
In the Google Cloud console, on the Navigation menu (
), select IAM & Admin > IAM.
-
Locate the network-admin service account in the permissions list and click the Edit principal (pencil) icon.
-
Change Role to Compute Engine > Compute Security Admin.
-
Click Save.
-
Return to Cloud Shell and retry deleting the firewall rule:
gcloud compute firewall-rules delete allow-http-web-server --quiet
The output should confirm deletion:
Deleted [https://www.googleapis.com/compute/v1/projects/.../global/firewalls/allow-http-web-server].
Note: The Security Admin role grants full authority over firewall rules, allowing the delete operation to succeed.
Verify firewall rule deletion
- Switch back to your student credentials in Cloud Shell:
gcloud config set account {{{user_0.username|STUDENT_EMAIL}}}
- Test external HTTP connectivity to the blue server again:
curl -m 3 http://$BLUE_EXTERNAL_IP
The connection hangs and times out, confirming that external HTTP access is blocked after the firewall rule was deleted.
Congratulations!
In this lab, you created two nginx web servers using automated startup scripts and controlled external HTTP access with tagged firewall rules. You also explored the separation of responsibilities between the Network Admin and Security Admin IAM roles.
Next steps / learn more
Google Cloud training and certification
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Manual Last Updated November 7, 2026
Lab Last Tested November 7, 2026
Copyright 2026 Google LLC. All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.