
准备工作
- 实验会创建一个 Google Cloud 项目和一些资源,供您使用限定的一段时间
- 实验有时间限制,并且没有暂停功能。如果您中途结束实验,则必须重新开始。
- 在屏幕左上角,点击开始实验即可开始
Create a Compute Engine template
/ 15
Create a Health Check
/ 15
Create a Managed Instance Group
/ 15
Create a Private Key and SSL certificate
/ 15
Create a load balancer
/ 15
Set up IAP
/ 15
Add principals to the IAP access list
/ 10
In this lab, you will learn how to secure Compute Engine workloads using Chrome Enterprise Premium's Identity Aware Proxy to restrict traffic based on identity.
The lab provisions a web based IDE that you will restrict access to via zero trust configuration.
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:
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 left is the Lab Details pane with the following:
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.
If necessary, copy the Username below and paste it into the Sign in dialog.
You can also find the Username in the Lab Details pane.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab Details pane.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
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:
When you are connected, you are already authenticated, and the project is set to your Project_ID,
gcloud
is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Output:
Output:
gcloud
, in Google Cloud, refer to the gcloud CLI overview guide.
In the Cloud Console, click Navigation menu () > Compute Engine > Instance Templates.
Click Create Instance Template.
On the Create an instance template page, specify the following, and leave the remaining settings as their defaults:
Property | Value |
---|---|
Location | Global |
Series | E2 |
Machine type | e2-micro (2 vCPU) |
Access scopes | Set access for each API |
Access scopes > Compute Engine | Read Only |
Firewall | Allow HTTP traffic, Allow HTTPs traffic |
Click Advanced options.
Click Management.
In Automation > Startup script, copy and paste the following script:
Click Check my progress to verify the objective.
In the Cloud Console, click Navigation menu () > Compute Engine > Health Checks.
Click the Create Health Check button.
On the Create a Health Check page, provide the following information:
Click Create.
Click Check my progress to verify the objective.
Navigate to Compute Engine > Instance Groups.
Click Create instance group.
Click New managed instance group (stateless) from the left-hand menu.
On the New managed instance group (stateless) page, specify the following, and leave the remaining settings as their defaults:
Field | Setting |
---|---|
Name | my-managed-instance-group |
Instance template | Select the instance template you created in Step 1 |
Location | Multiple zones |
Region | |
Autoscaling mode | Off: Do not autoscale |
Number of instances | To change the number of instances, you must first turn off autoscaling; see below. When this is done, set the maximum number value to 3 |
Autohealing | Select the Health Check dropdown, then select the health check created in the previous section, my-health-check
|
Click Check my progress to verify the objective.
If you already have a private key and a certificate from a certificate authority (CA), skip this section and go to Creating an SSL certificate resource. Otherwise, open Cloud Shell and perform the steps below.
A Google Cloud SSL certificate includes both a private key and the certificate itself, both in PEM format. Your private key must meet the following criteria:
You can create a new private key with RSA-2048 encryption in the PEM format using the following OpenSSL command.
After you have a private key, you can generate a certificate signing request (CSR) in the PEM format using OpenSSL. Your CSR must meet the following criteria:
CN
) or a subject alternative name (SAN
) attribute. Practically speaking, your certificate should contain both CN
and SAN
attributes, even if it is for a single domain—modern clients, like the current versions of macOS and iOS don't rely on just the CN
attribute.When a Certificate Authority (CA) signs your CSR, it uses its own private key to create a certificate.
Using a publicly-trusted CA
Managing your own CA
Using a self-signed certificate
If you manage your own CA, or if you want to create a self-signed certificate for testing, you can use the following OpenSSL command:
Wildcards in common names
Your self-managed SSL certificates can use a wildcard in the common name. For example, a certificate with the common name *.example.com.
matches the hostnames www.example.com
and foo.example.com
, but not a.b.example.com
or example.com.
When the load balancer selects a certificate, it always prefers to match a hostname to certificates without wildcards over certificates with wildcards.
Certificates with wildcard fragments, such as f*.example.com
, aren't supported.
Before you can create a Google Cloud SSL certificate resource, you must have a private key and certificate. Refer to Creating a private key and certificate if you have not already created or obtained them.
To create a global SSL certificate, use the gcloud compute ssl-certificates create
command with the --global
flag:
Click Check my progress to verify the objective.
In the Cloud Console, click Navigation menu () > View All Products > under Networking section click on Network Services then click Create Load Balancer.
Select Application Load Balancer (HTTP/HTTPS) and Next.
Select Public facing (external) and Next.
Select Best for global workloads and Next.
Select Global external Application Load Balancer and Next.
Select Configure.
On the Create global external Application Load Balancer page that appears, enter name as my-load-balancer
for your load balancer.
Click Backend configuration, then select Backend services & backend buckets > Create a backend service.
On the Create backend service panel, in the Name box, enter my-backend-service
.
Under Health check, select my-health-check.
When you're finished updating values, click Create. The Create global external Application Load Balancer panel reappears.
Click Routing rules to load the default values. You don't need to add any rules.
Click Frontend configuration. Use the default values except for the following:
Protocol: HTTPS (includes HTTP/2 and HTTP/3)
IP address: Click Ephemeral, and then select Create IP address
Name: Type static-ip
Click Reserve to reserve the static IP address.
Certificate: my-cert
When you're finished entering frontend configuration values, click Done. The Create global external Application Load Balancer panel reappears.
Under Create global external Application Load Balancer, click Create. The Load balancing page appears and your new load balancer will be created in the list of load balancers.
After the Cloud Console finishes creating the new load balancer, click the name of the load balancer and note the external IP address under Details > Frontend. You will need it in the next step.
To correctly authenticate requests from IAP, you must restart the VMs in your MIG by following the steps below:
Click Check my progress to verify the objective.
Next, you'll configure your firewall to block access to the underlying VMs and only allow access through IAP:
In the console to to VPC network > Firewall rules.
Select the checkbox next to default-allow-internal
.
Click Delete and select delete again to confirm it.
Click Create firewall rule and set the following values:
80, 78
When you're finished updating values, click Create.
To set up IAP for your project, follow the steps below:
a. Go to the OAuth consent screen
b. Click Get Started.
c. Enter the App name you want to display.
d. Under User Support email, select the email address you want to display as a public contact. The email address must belong to the currently logged in user account or to a Google Group of which the currently logged in user belongs.
e. Click Next.
f. For Audience, select External, and then click Next.
g. Enter the same email address in the Developer contact information.
h. Click Next.
i. Click Checkbox to agree the User Data Policy, then click Continue, and then click Create.
To change information on the OAuth consent screen later, such as the product name or email address, repeat the preceding steps to configure the consent screen.
GO TO THE IDENTITY-AWARE PROXY PAGE and select a project. Click Go to Identity-Aware Proxy.
Next to my-backend-service, toggle the on/off switch in the IAP column.
In the Turn on IAP window that appears, select the checkbox next to "I have read the configuration requirements and configured my Compute Engine resource according to documentation."
Click Turn on.
Click Check my progress to verify the objective.
Next, add principals to the IAP access list for your project.
In the Cloud Console, click Navigation menu () > IAM & admin > Identity-Aware Proxy and select the my-backend-service checkbox. Click Add Principal.
Enter the following to grant access to yourself.
New Principals: Enter your qwiklabs account email here
Role: IAP-secured Web App User
Click Save.
Click Check my progress to verify the objective.
You will see an IAP generated response that is true
— this means you have successfully configured IAP for your GCE instance.
This should show the 302 redirection to accounts.google.com if you click on the External IP address
link.
If you follow the URL, you should see a page similar to the following:
Because you used a self-signed cert, you won’t be able to access the application itself. However, this confirms that IAP is configured and is protecting traffic.
You have successfully secured a web application running on a compute engine instance using Identity Aware Proxy.
In this lab, you learned to:
...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 June 11, 2025
Lab Last Tested June 11, 2025
When you have completed your lab, click End Lab. Your account and the resources you've used are removed from the lab platform.
You will be given an opportunity to rate the lab experience. Select the applicable number of stars, type a comment, and then click Submit.
The number of stars indicates the following:
You can close the dialog box if you don't want to provide feedback.
For feedback, suggestions, or corrections, please use the Support tab.
Copyright 2025 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.
此内容目前不可用
一旦可用,我们会通过电子邮件告知您
太好了!
一旦可用,我们会通过电子邮件告知您
一次一个实验
确认结束所有现有实验并开始此实验