- Lab
- A Cloud Guru
Create a VM Scale Set in Azure with Terraform
Hey, Gurus! Welcome to the Create a VM Scale Set in Azure with Terraform lab. In this lab, we will cover these 4 objectives: 1. First, we will log into the Azure Portal, configure the Cloud Shell, and download and run the lab setup script to setup the lab. 1. Second, we will import the resource group. 1. Third, we will add our VM scale set to our configuration and set CPU thresholds to allow for autoscaling. 1. And for the fourth objective, we will add a jumpbox to our configuration to give us a server to connect to that we can use to connect to our cluster. We will then deploy our VM cluster resources.
Path Info
Table of Contents
-
Challenge
Set Up Cloud Shell and the Lab Environment
In the Portal
- Go to the Azure Portal and log in using your lab credentials.
- Click the Cloud Shell icon next to the search bar in the Portal.
- Select Bash at the prompt.
- Click Show advanced settings.
- Set the Cloud Shell region to the same location as the resource group.
- Select the existing Resource group, and select Use Existing for the Storage account.
- In the File share section, choose Create new and enter "terraform".
- Click Create storage.
- Download the
lab_6_setup.sh
script athttps://github.com/ACloudGuru/advanced-terraform-with-azure/raw/main/lab_vm_scale_set_resources/lab_6_setup.sh
. - Add execute permissions to the script.
- Run the lab_6_setup.sh script.
-
Challenge
Import the Resource Group into Terraform
In the Cloud Shell
- In the Cloud Shell, review the
networking.tf
. - Make note of the resource group name and label at the top and then close the file.
- Run the
az group list
command to get the subscription id. - Import your resource group into Terraform using the resource name, label, and subscription id.
- After the import, add the name and location of your resource group to the
networking.tf
file so it looks like the code below (fill in with your resource group and location):resource "azurerm_resource_group" "guru" { name = "<RESOURCE_GROUP>" location = "<LOCATION>" }
- Save the file.
- In the Cloud Shell, review the
-
Challenge
Define the Azure VM Scale Set
In the Cloud Shell
- Create a file called
vmss.tf
file. - Define the vm scale set configuration so it will deply a 2 vm cluster.
- Use variables to define the location, admin_username, admin_password, and tags.
- Make sure you associate your scale set with your subnet and load balancer backend pool in the
networking.tf
file. - Save the changes.
- Create a file called
-
Challenge
Define the Jumpbox Configuration
In the Cloud Shell
- Create a file called
jumpbox.tf
file. - Define the jumpbox vm configuration.
- Use variables to define the location, admin_username, admin_password, and tags..
- Make sure you create a network interface and a public ip for your jumpbox.
- Save the changes.
- Create a file called
-
Challenge
Create the Variables and Outputs, then Deploy
In the Cloud Shell
- Create the
variables.tf
file and define these variables: a) location b) tags c) application port (used in thenetworking.tf
file) d) admin_user e) admin_password - Create the
output.tf
file and define these output variables: a) vmss_public_ip_fqdn b) jumpbox_public_ip_fqdn c) jumpbox_public_ip - Create the
web.conf
file and add the Nginx package to the config. This will configure your cluster to run Nginx. - Save both files and apply your configuration.
- Confirm you have successfull deployed your resources and you can interact with your cluster.
- Create the
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.