hands-on lab

Working with Terraform Provisioners in GCP

Difficulty: Beginner
Duration: Up to 30 minutes
Students: 299
Rating: 5/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.

Description

Terraform uses HCL, a declarative language that is great for managing the abundance of cloud resources. This may introduce pain points in automation tasks where procedural languages like PowerShell or Bash perform better.

Terraform provisioners can help with this by automating additional setup or teardown requirements after a resource is created or before it is deleted. Provisioners can be a powerful tool in the Terraform developer's toolbelt, but they do come at a cost.

Incorporating the use of provisioners adds complexity to your deployment and may introduce additional networking or dependency pain points. This is why it is important to be aware of how to use provisioners and understand that they should be used as a last resort when developing a solution.

It is important to note that Terraform provisioners should be used as a last resort when developing your solutions. This lab covers Terraform provisioners and how to configure them, but be aware that the solution provided is for demonstration purposes only. More suitable solutions exist for the desired outcome presented in this lab.

In this lab, you will configure both creation and deletion provisioners and learn how and when Terraform utilizes them during a deployment.

Learning Objectives

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

  • Configure creation-time and destroy-time provisioners in your Terraform deployments

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

Covered topics

Lab steps

Activating the Google Cloud Platform Service Account
Creating Terraform Provisioners in GCP