Creating Variables in Terraform Configurations in Azure

Lab Steps

Create Variables for the Azure Terraform Configuration

The hands-on lab is part of this learning path

Ready for the real environment experience?

Time Limit1h 40m


Variables are a critical component of developing Terraform code. They allow configurations to become dynamic and reusable by enabling them to take input values during deployment. By incorporating variables into your Terraform code, the same code used to deploy a Virtual Machine into an environment can be used to deploy into another. This strategy can improve the speed and efficiency of teams. For example, a database server takes a DB expert to install the server and configure the database to the most optimal settings. With Terraform, a database server build can be defined in code and use variables to configure the server's unique values for each environment. Other team members can then use the code to deploy the same configuration without the database expertise. 

In this lab, you will learn how to create reusable Terraform configurations using variables. 

Learning Objectives

Upon completion of this lab you will be able to:

  • Understand how to create Terraform variables
  • Know the benefits of using variables

Intended Audience

This lab is intended for:

  • Individuals studying to take the HashiCorp Certified: Terraform Associate exam
  • Anyone interested in learning how to use Terraform to manage Cloud Service Providers


You should be familiar with:

  • Cloud Services
  • DevOps
  • Basic understanding of Terraform deployments

The following course and lab can be used to fulfill the prerequisites:

Environment before
Environment after
About the Author
Learning paths5

Luke is a Site Reliability Engineer at Microsoft. His background is infrastructure development using Terraform and in 2021 he was awarded the HashiCorp Ambassador award. He is an Azure DevOps Engineer Expert, Azure Administrator Associate, and HashiCorp Certified - Terraform Associate.