Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Azure icon
Labs

Create a VM Cluster in Azure with Terraform

In this lab, you are asked to start building out an app server cluster for a comic reader that you are working on for your employer for digital comics. To do this, you will configure Cloud Shell and run the lab setup script; import the resource group; deploy the Azure Storage account configuration; and add the VM cluster configuration and deploy your cluster.

Azure icon
Labs

Path Info

Level
Clock icon Advanced
Duration
Clock icon 45m
Published
Clock icon Jun 17, 2022

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Set Up Cloud Shell and the Lab Environment

    In the Portal

    1. Click the Cloud Shell icon (>_) in the upper right.

    2. Select Bash.

    3. In the Getting started pane, select No storage account required for an ephemeral session.

    4. Using the dropdown menu, select the only subscription available.

    5. Click Apply.

    6. In Cloud Shell, create the clouddrive directory:

      mkdir clouddrive
      
    7. Change directory:

      cd clouddrive
      
    8. Download the lab_5_setup.sh script: https://raw.githubusercontent.com/ACloudGuru/advanced-terraform-with-azure/main/lab_vm_cluster_resources/lab_5_setup.sh

    9. Add execute permissions to the script.

    10. Run the lab_5_setup.sh script.

  2. Challenge

    Import the Resource Group

    In the Cloud Shell

    1. In the Cloud Shell, review the networking.tf file.

    2. Make note of the resource group and label, and then close the file.

    3. Run the az group list command to get the subscription ID.

    4. Import your resource group into Terraform using the resource name, label, and subscription ID.

    5. 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" "comics" {
          name     = "<RESOURCE_GROUP>"
          location = "<LOCATION>"
      }
      
    6. Save the file.

  3. Challenge

    Define Your Cluster Config and Output Variables

    In the Cloud Shell

    1. Create a file called vms.tf.
    2. Define the VM configuration so it will deploy a two-VM cluster using count.
    3. Make sure you associate your VMs with your subnet and load balancer backend pool in the networking.tf file, and adjust for the multiple resources in your configuration.
    4. Save the changes.
    5. Create a file called output.tf.
    6. Define the these outputs:
      • Resource group
      • Private IP of the first VM
      • Private IP of the second VM
      • Public IP
      • Resource group location
    7. Save the changes.
  4. Challenge

    Add the VM Cluster Terraform Config and Deploy

    In the Cloud Shell

    1. Apply your configuration.
    2. Confirm you have successfully deployed your VM cluster.

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

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.

Start learning by doing today

View Plans