
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Confirm OAuth Consent has been setup
/ 30
Allow a principal to access the application by configuring IAM
/ 30
Restrict access with IAP
/ 40
In this lab, you secure Compute Engine workloads using BeyondCorp Enterprise’s Identity-Aware Proxy (IAP) to restrict traffic based on identity.
IAP is a feature of BeyondCorp Enterprise, Google Cloud's zero-trust solution that enables an organization's workforce to access web applications securely from anywhere, without the need for VPN and without fear of malware, phishing, and data loss.
This lab provisions a web-based integrated development environment (IDE) that you will restrict access to by enabling zero-trust configuration.
In this lab, you learn how to perform the following tasks:
This Qwiklabs hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that 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 pop-up opens for you to select your payment method. On the left is a panel populated with the temporary credentials that you must use for this lab.
Copy the username, and then click Open Google Console. The lab spins up resources, and then opens another tab that shows the Choose an account page.
On the Choose an account page, click Use Another Account. The Sign in page opens.
Paste the username that you copied from the Connection Details panel. Then copy and paste the password.
After a few moments, the Cloud console opens in this tab.
Google 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.
Google Cloud Shell provides command-line access to your Google Cloud resources.
In Cloud console, on the top right toolbar, click the Open Cloud Shell button.
Click Continue.
It takes a few moments to provision and connect to the environment. When you are connected, you are already authenticated, and the project is set to your PROJECT_ID. For example:
gcloud is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Output:
Example output:
Output:
Example output:
In this task you create an instance template. This is a resource that you use to create virtual machine (VM) instances and managed instance groups (MIGs).
In the Google Cloud console, in the Navigation menu (), click 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 |
Click Advanced options.
Click Management.
In Automation > Startup script, copy and paste the following script:
It takes a few moments to create your instance template.
In this task you create a managed instance group (MIG), a collection of virtual machine (VM) instances that you manage as a single entity.
In the Google Cloud console, in the Navigation menu (), click 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:
Property | Value |
---|---|
Name | my-managed-instance-group |
Instance template | Select the instance template you created in Task 1. |
Location | Multiple zones |
Region | us-central1 (Iowa) |
Autoscaling > 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. |
It will take a few minutes to create the MIG.
In this task you create a private key, a certificate, and then a self-managed SSL certificate resource. Before you can create a Google Cloud SSL certificate resource, you must have a private key and certificate.
A Google Cloud SSL certificate includes both a private key and the certificate itself, both in PEM format.
Self-managed SSL certificates are certificates that you obtain, provision, and renew yourself. You use this resource to secure communication between clients and your load balancer, which you create in the next task.
On the Google Cloud console title bar, click Activate Cloud Shell (). If prompted, click Continue.
To create a new private key with RSA-2048 encryption in the PEM format OpenSSL, run the following command:
Generate a certificate signing request (CSR) in the PEM format using OpenSSL.
Click Open Editor. If prompted, click Open in a new window.
In Cloud Shell Editor, click the menu and select File > New File.
For the filename, type ssl_config, and press enter.
Ensure the create file location is shown as /home > student-XX-XXXXXXXXX/ssl_config and then click OK.
Copy and paste the following configuration into the Cloud Editor window:
Click the menu and select File > Save.
Return to the previous tab. You may have to click Open Terminal to resume your Cloud Shell session.
To create a certificate signing request (CSR) file, run the following OpenSSL command:
When a Certificate Authority (CA) signs your CSR, it uses its own private key to create a certificate.
Before you can create a Google Cloud SSL certificate resource, you must have a private key and certificate.
gcloud compute ssl-certificates create
command with the --global
flag:In this task you create a load balancer. HTTP(S) Load Balancing is implemented on Google Front End (GFE). GFEs are distributed globally and operate together using Google's global network and control plane.
To set up a load balancer, your VMs must be in an instance group, which you created in the previous tasks.
In the Google Cloud console, in the Navigation menu (), click on View All Products and click Network services > Load balancing.
Click Create Load Balancer.
Under Application Load Balancer (HTTP/S), click Next.
Under Under Public facing or internal only, select Public facing (external), click Next.
Under Global or single region deployment, select Best for global workloads, click Next.
Under Load balancer generation, select Global external Application Load Balancer, click Next.
Click Configure.
For Load Balancer Name, type my-load-balancer.
Click Backend Configuration > Backend services & backend buckets > Create a Backend Service.
On the Create backend service panel, for Name, type my-backend-service.
You must use the exact name my-backend-service. If you use a different name, the startup script on your VMs won't be able to find the correct Backend Service ID to authenticate requests.
In New backend, specify the following, and leave the remaining settings as their defaults:
Property | Value |
---|---|
Instance group | my-managed-instance-group |
Port Numbers | 80 |
Uncheck Enable Cloud CDN.
In Health check, click Create a Health Check.
For Name, type my-health-check.
For Protocol, select HTTP.
Click Save.
Click Create.
The Create global external Application Load balancer pane reappears.
Property | Value |
---|---|
Protocol | Https (includes HTTP/2 and HTTP/3) |
IP address | Click Ephemeral, and then select Create IP address |
Name | Type static-ip, and then click Reserve. |
Certificate | my-cert |
The Create global external Application Load balancer pane reappears.
The Load balancing page appears and your new load balancer will be created in the list of load balancers.
In this task you restart the VMs in your MIG so that they can correctly authenticate requests from IAP.
In the Google Cloud console, in the Navigation menu (), click Compute Engine > Instance groups.
Click my-managed-instance-group.
Click Restart/Replace VMs.
For Operation, click Restart.
For Instances, type 3
For Minimum wait time, type 0
Click Restart VMs.
In this task you configure your firewall to block access to the underlying VMs and only allow access through IAP.
In the Google Cloud console, in the Navigation menu (), click VPC network > Firewall.
Select the default-allow-internal checkbox.
Click Delete, and then select Delete to confirm it.
Click Create Firewall Rule. Specify the following, and leave the remaining settings as their defaults:
Property | Value |
---|---|
Name | allow-iap-traffic |
Targets | All instances in the network |
Source IPv4 ranges | 130.211.0.0/22, 35.191.0.0/16 (Press Enter after you paste each value in the box) |
Protocols and ports | Specified protocols and ports |
TCP | 80 |
In this step you set up IAP for your project.
In the Google Cloud console, in the Navigation menu (), click Security > Identity-Aware Proxy.
Click Enable API.
Click Go to Identity Aware Proxy.
Click Configure Consent Screen.
Click GET STARTED.
In App name , type IAP.
In User support email, select the student account. This has the value of student-00-*****@qwiklabs.net and then click NEXT.
For Audience select External , then click NEXT.
For Contact information, copy and paste the student account Username from the lab window. This matches the value in the previous step.
Click NEXT then check the box to agree to the user data policy. Finally, click Create.
Next, go back to the first browser tab.
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.
In the Google Cloud console, in the Navigation menu (), click Security > Identity-Aware Proxy.
Next to my-backend-service, toggle the on/off switch in the IAP column.
In the Turn on IAP dialog, select the checkbox to confirm you have read the configuration requirements.
Click Turn On.
In this step you add principals to the IAP access list for your project.
In Identity-Aware Proxy, select the my backend-service checkbox.
Click Add Principal.
To grant access to yourself, in New Principals, copy and paste your qwiklabs Username from the lab credentials pane.
Select the Role of Cloud IAP > IAP-secured Web App User.
Click Save.
In the task, you run a curl command to test access your external load balancer, and then verify that it is protected by IAP.
In the Google Cloud console, in the Navigation menu (), click on View All Products and click Network services > Load balancing.
Click Frontends.
On the Google Cloud console title bar, click Activate Cloud Shell (). If prompted, click Continue.
Run the following curl command, replacing Load Balancer External IP address with the External IP address of your load balancer:
Scroll up the console page and locate the Http/2 302 redirection to accounts.google.com.
Click on the location link.
The link opens to the Google account integrated authentication page.
You have successfully used IAP to secure a web application running on a Compute Engine instance.
In this lab, you learned how to:
When you have completed your lab, click End Lab. Google Cloud Skills Boost removes the resources you’ve used and cleans the account for you.
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 2022 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.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one