
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
Import infrastructure
/ 20
Configure a remote backend
/ 10
Modify and update infrastructure
/ 20
Destroy resources
/ 10
Use a Module from the Registry
/ 20
Configure a firewall
/ 20
In a challenge lab you’re given a scenario and a set of tasks. Instead of following step-by-step instructions, you will use the skills learned from the labs in the course to figure out how to complete the tasks on your own! An automated scoring system (shown on this page) will provide feedback on whether you have completed your tasks correctly.
When you take a challenge lab, you will not be taught new Google Cloud concepts. You are expected to extend your learned skills, like changing default values and reading and researching error messages to fix your own mistakes.
To score 100% you must successfully complete all tasks within the time period!
This lab is recommended for students who have enrolled in the Build Infrastructure with Terraform on Google Cloud course. Are you ready for the challenge?
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:
You are a cloud engineer intern for a new startup. For your first project, your new boss has tasked you with creating infrastructure in a quick and efficient manner and generating a mechanism to keep track of it for future reference and changes. You have been directed to use Terraform to complete the project.
For this project, you will use Terraform to create, deploy, and keep track of infrastructure on the startup's preferred provider, Google Cloud. You will also need to import some mismanaged instances into your configuration and fix them.
In this lab, you will use Terraform to import and create multiple VM instances, a VPC network with two subnetworks, and a firewall rule for the VPC to allow connections between the two instances. You will also create a Cloud Storage bucket to host your remote backend.
plan
and apply
your changes to allow your work to be successfully verified. Since we will be updating many terraform files in this lab make sure to use the correct file path and maintain the correct indentation. variables.tf
files in the root directory and within the modules. Add three variables to each file: region
, zone
, and project_id
. For their default values, use Add the Terraform block and the Google Provider to the main.tf
file. Verify the zone argument is added along with the project and region arguments in the Google Provider block.
Initialize Terraform.
main.tf
file then re-initialize Terraform.instances.tf
file to match the pre-existing instances.
tf-instance-1
and tf-instance-2
.machine_type
, boot_disk
, network_interface
, metadata_startup_script
, and allow_stopping_for_update
. For the last two arguments, use the following configuration as this will ensure you won't need to recreate it:terraform import
command to import them into your instances module.apply
will update the instances in-place. This is fine for lab purposes, but in a production environment, you should make sure to fill out all of the arguments correctly before importing.Click Check my progress to verify the objective.
Create a Cloud Storage bucket resource inside the storage
module. For the bucket name, use
location = "US"
force_destroy = true
uniform_bucket_level_access = true
outputs.tf
file. Add the module reference to the main.tf
file. Initialize the module and apply
the changes to create the bucket using Terraform.
Configure this storage bucket as the remote backend inside the main.tf
file. Be sure to use the prefix terraform/state
so it can be graded successfully.
If you've written the configuration correctly, upon init
, Terraform will ask whether you want to copy the existing state data to the new backend. Type yes
at the prompt.
Click Check my progress to verify the objective.
Navigate to the instances module and modify the tf-instance-1 resource to use an e2-standard-2
machine type.
Modify the tf-instance-2 resource to use an e2-standard-2
machine type.
Add a third instance resource and name it e2-standard-2
machine type. Make sure to change the machine type to e2-standard-2
to all the three instances.
Initialize Terraform and apply
your changes.
outputs.tf
file within the module. Click Check my progress to verify the objective.
apply
the changes.Click Check my progress to verify the objective.
In the Terraform Registry, browse to the Network Module.
Add this module to your main.tf
file. Use the following configurations:
6.0.0
(different versions might cause compatibility errors).subnet-01
and subnet-02
. For the subnets arguments, you just need the Name, IP, and Region.10.10.10.0/24
for subnet-01
, and 10.10.20.0/24
for subnet-02
.Once you've written the module configuration, initialize Terraform and run an apply
to create the networks.
Next, navigate to the instances.tf
file and update the configuration resources to connect tf-instance-1 to subnet-01
and tf-instance-2 to subnet-02
.
, and then add the subnetwork argument with the correct subnet for each instance.
Click Check my progress to verify the objective.
main.tf
file, and name it tf-firewall.
0.0.0.0/0
) on TCP port 80.source_ranges
argument with the correct IP range (0.0.0.0/0
).apply
your changes.network
argument, you can inspect the state and find the ID or self_link of the google_compute_network
resource you created. It will be in the form projects/PROJECT_ID/global/networks/
.
Click Check my progress to verify the objective.
If you managed to import, create, modify, and configure the architecture within the allotted time, you've shown great competency in your Terraform skills! In this lab, you started by importing two pre-configured VMs into Terraform and creating a Cloud Storage bucket to configure your backend. You then added another instance and practiced modifying and updating the resource configurations within your modules. Lastly, you used a module from the Terraform Registry to create a VPC with two subnets, connected the instances to it, and created a firewall rule to allow connections between them.
This self-paced lab is part of the Build Infrastructure with Terraform on Google Cloud skill badge course. Completing this skill badge course earns you the badge above, to recognize your achievement. Share your badge on your resume and social platforms, and announce your accomplishment using #GoogleCloudBadge.
Now that you have shown competency in Terraform, you may want to register for the HashiCorp Infrastructure Automation Certification. The Terraform Associate certification is for Cloud Engineers specializing in operations, IT, or development who know the basic concepts and skills associated with open source HashiCorp Terraform. Candidates will be best prepared for this exam if they have professional experience using Terraform in production, but performing the exam objectives in a personal demo environment may also be sufficient. So, if you want to take your skills to the next level and verify your infrastructure automation abilities, we recommend that you review the study guide and the exam review, and then register for the exam when you're ready. Good luck!
...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 May 14, 2024
Lab Last Tested May 14, 2024
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.
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