- Lab
- A Cloud Guru
Deploy an Azure VM Scale Set with Load Balancing
Welcome to the Deploy a VM Scale Set with Load Balancing lab. In this lab, we will cover three objectives: 1. Use an existing subnet as a data source 1. Create and configure an Azure load balancer 1. Create and configure an Azure VM Scale Set By the end of this lab, you will have created an Azure VM Scale Set and load balancer using Terraform and a module from the public registry.
Path Info
Table of Contents
-
Challenge
Use an Existing Subnet as a Data Source
In this objective, you'll add a existing Azure subnet as a data source to your Terraform configuration. This subnet will be used for the network interfaces of the VM Scale Set.
- Log into the Azure CLI using the provided credentials
- Retrive the name of the provided resource group and virtual network.
- Create a new Terraform configuration using the
azurerm
. - Set
skip_provider_registration
to true for theazurerm
provider block. - Create data sources for the existing resource group and subnet named
web
. - Create the necessary input variables and
terraform.tfvars
file. - Add an output to display the subnet ID.
- Deploy the configuration and verify the correct output is displayed in the terminal.
-
Challenge
Create and Configure an Azure Load Balancer
In this objective, you will add a public-facing Azure load balancer using the module from the public registry. The load balancer should listen on port 80 for traffic and send it to the application port defined for the VM Scale Set. The health probe should sent an HTTP request to the
"/"
path on the application port defined for the VM Scale Set.- Add the load balancer module to your configuration using the existing resource group provided by the lab, with the following values:
- type = "public"
- pip_sku = "Standard"
- allocation_method = "Static"
- lb_sku = "Standard"
- Add an
lb_port
entry listening on port80
and sending traffic to the defined application port. - Add an
lb_probe
entry the checks the path "/" on the defined application port. - Validate and deploy the configuration.
- Add the load balancer module to your configuration using the existing resource group provided by the lab, with the following values:
-
Challenge
Create and configure an Azure VM Scale Set
In this objective, you will add an Azure VM Scale Set and network security group to the configuration using the provided subnet and startup script. The network security group should allow traffic from anywhere on the defined application port.
- Add an
azurerm_network_security_group
andazurerm_network_security_rule
to the configuration. The rule should allow TCP traffic from any source address and port to the defined application port of the VM Scale Set. - Add a TLS private key for the VM Scale Set configuration.
- Add a
custom_data.tpl
file with the linked contents from the course repository. - Add an
azurerm_linux_virtual_machine_scale_set
resource to your configuration using the following values:- publisher = "Canonical"
- offer = "0001-com-ubuntu-server-jammy"
- sku = "22_04-lts"
- version = "latest"
- Include a reference to the network security group and load balancer backend pool in the
network_interface
block. - Include the
health_probe_id
argument referring to the health probe created by the load balancer module. - Add the necessary input variables to the
variables.tf
file and add the values to theterraform.tfvars
file. - Add an output for the public IP address of the load balancer.
- Validate and deploy the configuration.
- Verify that you can reach the website at the public IP address and port.
- Add an
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.