Provisioning an Azure VM with Terraform Modules

The hands-on lab is part of this learning path

Lab Steps

Logging into the Microsoft Azure Portal
Starting an Azure Cloud Shell
Initializing Terraform with the Azure Provider
Setting Up a Data Source to Reference the Lab Resource Group
Using a VNet Module from the Terraform Registry
Using a Security Module from the Terraform Registry
Creating a Local Module for Provisioning Azure VMs
Provisioning an Azure VM with the Local Terraform Module
Validate Provisioning an Azure VM with Terraform Modules

Ready for the real environment experience?

DifficultyAdvanced
Max Duration1h
Students532
Ratings
4.7/5

Description

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

The following Labs can be used to fulfill the prerequisites to this Lab:

Lab Environment

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

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

Updates

Sept. 20th, 2019 - Resolved an issue that caused end of lab validation check to fail to complete

Sept. 6th, 2019 - Updated to the latest version of Terraform in Azure Cloud Shell, and resolved an issue causing an error in the VM provisioning phase

June 26th, 2019 - Updated all instructions and images to match the latest Terraform and Azure Cloud Shell experience

May 6th, 2019 - Added Lab validation Lab Step to check the work performed in the Lab

May 6th, 2019 - Fixed an issue with the latest AzureRM Terraform provider attempting to register unnecessary Resource Providers and updated screenshots to reflect the latest experience

September 7, 2018 - Updated images to improve lab experience

About the Author

Students36610
Labs97
Courses11
Learning paths7

Logan has been involved in software development and research since 2007 and has been in the cloud since 2012. He is an AWS Certified DevOps Engineer - Professional, AWS Certified Solutions Architect - Professional, Microsoft Certified Azure Solutions Architect Expert, MCSE: Cloud Platform and Infrastructure, Google Cloud Certified Associate Cloud Engineer, Certified Kubernetes Administrator (CKA), Certified Kubernetes Application Developer (CKAD), Linux Foundation Certified System Administrator (LFCS), and Certified OpenStack Administrator (COA). He earned his Ph.D. studying design automation and enjoys all things tech.

Covered Topics