hands-on lab

Creating Variables in Terraform Configurations

Beginner
45m
3,291
4.7/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

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 an EC2 into one 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 beginner-level 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

Prerequisites

You should be familiar with:

Updates

November 14th, 2023 - Lab updated to utilize CodeTour IDE

April 24th, 2023 - Resolved IDE delay

Environment before
Environment after
About the author
Avatar
Jun Fritz
Cloud Labs Developer
Students
39,042
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
Create Variables for the Terraform Configuration