hands-on lab

Working with Terraform Configuration Variables in GCP

Beginner
45m
312
4.6/5
Get guided in a real environmentPractice with a step-by-step scenario in a real, provisioned environment.
Learn and validateUse validations to check your solutions every step of the way.
See resultsTrack your knowledge and monitor your progress.
Lab description

Configuring variables is a critical component of developing infrastructure with Terraform. Variables allow for dynamic deployments and enable developers the ability to reuse patterns in their infrastructure. Variables can be passed in at the start of the deployment, configured alongside the cloud resources, or returned to the user after a successful deployment.

By incorporating variables into your deployments, you eliminate the need to hard-code specific configurations, which improves code maintainability and troubleshooting. Your Terraform infrastructure can then be shared with others so they can implement the same solution using their unique resource configurations that fit their needs.

In this lab, you will learn how to refactor Terraform resource definitions to allow for code reuse with variables.

Learning Objectives

Upon completion of this lab, you will be able to:

  • Configure and utilize variables in your Terraform deployments
  • Define output variables in Terraform

Intended Audience

  • Individuals looking to pass the HashiCorp Certified: Terraform Associate Exam
  • Individuals and teams seeking an introduction to using Terraform with Google Cloud Platform

Prerequisites

Familiarity with the following will be beneficial but is not required:

  • Basic concepts of Google Cloud Platform

Updates

April 27th, 2023 - Updated theia to enable autosave

Environment before
Environment after
About the author
Avatar
Jun Fritz
Cloud Labs Developer
Students
38,452
Labs
103
Courses
1
Learning paths
6

Jun is a Cloud Labs Developer with previous experience as a Software Engineer and Cloud Developer. He holds the AWS Certified Solutions Architect and DevOps Engineer Professional certifications. He also holds the AWS Certified Solutions Architect, Developer, and SysOps Administrator Associate certifications. 

Jun is focused on giving back to the growing cloud community by sharing his knowledge and experience with students and creating engaging content. 

Covered topics
Lab steps
Activating the Google Cloud Platform Service Account
Declaring Terraform Variables and Setting Values Using the Command Line
Leveraging Terraform Variable Configuration Files