Provisioning an Azure VM with Terraform Modules


28 students completed the lab in ~36m

Total available time: 1h:0m

Be the first to rate this lab!

Lab Overview

Terraform by HashiCorp can manage your infrastructure across multiple cloud providers and on-prem. To reuse and share components across projects and to better organize large projects, you can create modules. In this Lab, you will use modules shared on the public Terraform Registry as well as a module that you create to provision a web server virtual machine in Azure. The Lab will also introduce you to Azure's browser-based Cloud Shell, which you will use to complete the Lab.

Lab Objectives

Upon completion of this Lab you will be able to:

  • Create reusable Terraform modules
  • Use Terraform modules shared on the Terraform Registry
  • Work with Terraform Data Sources
  • Use Terraform Provisioners to bootstrap VMs
  • Learn how to use Azure Cloud Shell

Lab Prerequisites

You should be familiar with:

  • Working at the command-line in Linux
  • Terraform basics

Lab Environment

Before completing the Lab instructions, the environment will look as follows:

After completing the Lab instructions, the environment should look similar to:

Follow these steps to learn by building helpful cloud resources

Logging into the Microsoft Azure portal

Begin the Lab by logging into the Microsoft Azure portal

Starting an Azure Cloud Shell

Learn how to start an Azure Cloud Shell

Initializing Terraform with the Azure Provider

Prepare your Terraform working directory for use with the Azure provider plugin

Setting Up a Data Source to Reference the Lab Resource Group

Add a data source to reference properties of the Lab's resource group

Using a VNet Module from the Terraform Registry

Create the Azure network infrastructure with the help of a Terraform Registry module

Using a Security Module from the Terraform Registry

Use a Terraform Registry module to create a network security group

Creating a Local Module for Provisioning Azure VMs

Create a local module to provision a VM in the VNet you created

Provisioning an Azure VM with the Local Terraform Module

Use the local module you created to provision a VM in Azure