hands-on lab

Understanding Terraform State with GCP

Up to 45m
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

Terraform state acts as a map between your cloud resources and their configurations. This state can be stored locally or remotely depending on the size of your project or team. Local state allows individuals and small teams to manage the resources that make up the infrastructure by providing a consistent representation of each resource and its current configuration.

Terraform state also provides a performance benefit by deploying only the necessary updates to your resources. Storing metadata such as resource dependencies keeps your infrastructure consistent and avoids deployment ordering issues.

Local state is managed by a default Terraform state file, which acts as the single source of truth for your cloud infrastructure.

In this lab, you will explore the declarative nature of Terraform state and the state configuration file. This lab will focus on local state and leave the topic of remote state for another lab.

Learning Objectives

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

  • Understand Terraform local state and the patterns involved in managing GCP infrastructure state
  • Discover potential security risks of maintaining state locally

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


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

  • Basic concepts of Google Cloud Platform


April 27th, 2023 - Updated theia to enable autosave

November 22nd, 2022 - Updated instructions to use debian-10 replacing debian-9



Environment before
Environment after
About the author
Jun Fritz, opens in a new tab
Cloud Labs Developer
Learning paths

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
Exploring Terraform State with GCP