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
Build the infrastructure
/ 25
Adding tags to the compute resource
/ 25
Change the infrastructure for machine-type
/ 25
Destroy the infrastructure
/ 25
Build the infrastructure
/ 25
Adding tags to the compute resource
/ 25
Change the infrastructure for machine-type
/ 25
Destroy the infrastructure
/ 25
In this lab, you will use Terraform to create, update, and destroy Google Cloud resources. You will start by defining Google Cloud as the provider.
You will then create a VM instance without mentioning the network to see how terraform parses the configuration code. You will then edit the code to add network and create a VM instance on Google Cloud.
You will explore how to update the VM instance. You will edit the existing configuration to add tags and then edit the machine type. You will then execute terraform commands to destroy the resources created.
In this lab you will learn how to perform the following tasks:
For each lab, you get a new Google Cloud project and set of resources for a fixed time at no cost.
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 the Lab Details panel 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 panel.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab Details panel.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
On the Google Cloud menu, click Activate Cloud Shell (). If a dialog box appears, click Continue.
If prompted, click Continue.
Confirm that Terraform is installed by running the following command:
The output should look like this (do not copy; this is example output):
Terraform comes pre-installed in Cloud Shell. With Terraform already installed, you can directly create some infrastructure.
main.tf file:Click Open Editor on the toolbar of Cloud Shell. Click Open in a new window to leave the Editor open in a separate tab.
Copy the following code in the main.tf file.
terraform init command.The output should look like this (do not copy; this is example output):
Let us try creating a compute instance without specifying the network parameter and see how terraform processes such configuration.
main.tf file, enter the following code block.Save the main.tf file by clicking File > Save.
Now run the following command to preview if the compute engine will be created.
google_compute_instance block.The final code in main.tf file will look like this:
terraform plan command to preview if the compute engine will be created.Click Authorize when prompted.
The output should look like this (do not copy; this is example output):
yes.The output should look like this (do not copy; this is example output):
Click Check my progress to verify the compute engine created.
In the Google Cloud console, verify that the resources were created.
In the Google Cloud console, in the Navigation menu (), click Compute Engine > VM instances.
View the terraform instance created.
In this task, we will be performing 2 types of changes to the infrastructure:
In addition to creating resources, Terraform can also make changes to those resources.
tags argument to the instance we just created so that it looks like this:terraform plan
terraform apply to update the instance.The output should look like this (do not copy; this is example output):
The prefix ~ means that Terraform will update the resource in-place.
yes when promoted, and Terraform will add the tags to your instance.Click Check my progress to verify the tags were added.
Machine type of a VM cannot be changed on a running VM. Let us see how terraform processes the change in machine type for a running VM.
e2-micro to e2-medium so that it looks like this:terraform plan
terraform apply again to update the instance.The terraform apply fails with a warning as shown below. (do not copy; this is example output)
machine_type, set allow_stopping_for_update argument to true so that the code looks like this:terraform plan
terraform apply again to update the instance.Respond yes when promoted.
Verify the change in machine-type and the tags added by navigating to the VM Instances in the Cloud console and clicking the terraform instance created.
Click Check my progress to verify the compute engine terraform machine type is e2-medium.
You have now seen how to build and change infrastructure. Before moving on to creating multiple resources and showing resource dependencies, you will see how to completely destroy your Terraform-managed infrastructure.
yes to execute this plan and destroy the infrastructure:The - prefix indicates that the instance and the network will be destroyed.
Click Check my progress to verify the infrastructure was destroyed.
In this lab, you learned how to:
When you have completed your lab, click End Lab. Google Skills 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 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.
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
Complete this quick step to start your lab.