hands-on lab

Working with Terraform Remote State in 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

Managing infrastructure state is a critical aspect of working with Terraform. As a project or team grows, so will the infrastructure state. With multiple developers accessing these resource configurations at the same time, maintaining the state of the infrastructure becomes the top priority. While there are benefits to using local state, managing your Terraform state from a remote source tends to offer a more secure, long-term solution.

By utilizing remote state, Terraform will store state in a remote source. This remote source can be accessed by members of a team and offer state locking features to avoid conflicts. It also will take advantage of the additional security provided by storage resources such as Google Cloud Storage buckets.

In this lab, you will configure a Terraform project to store and manage state from a remote Google Cloud Storage bucket.

Learning Objectives

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

  • Understand how Terraform stores and manages state from a remote source
  • Configure remote state for a Google Cloud Platform infrastructure

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


June 9th, 2023 - Updated instance image

April 27th, 2023 - Updated theia to enable autosave

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
Configuring Terraform Remote State in GCP