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

Using the Virtual Machine Module

Welcome to the Using the Virtual Machine Module lab. In this lab, we will cover three objectives: 1. Use an existing subnet as a data source 1. Deploy an Azure VM using the Virtual Machine Module 1. Add a Network Security Group to the VM By the end of this lab, you'll have successfully deployed Azure VMs to an existing subnet and added security groups to the VMs to access a web page.

Azure icon
Labs

Path Info

Level
Clock icon Intermediate
Duration
Clock icon 30m
Published
Clock icon May 02, 2024

Contact sales

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

Table of Contents

  1. Challenge

    Use an Existing Subnet as a Data Source

    In this objective, you will add an existing subnet as a data source to use in the deployment of the Azure VM.

    1. Log into the Azure CLI using the provided credentials.
    2. Retrive the provided resource group and virtual network names.
    3. Create a new Terraform configuration using the azurerm.
    4. Set skip_provider_registration to true for the azurerm provider block.
    5. Create data sources for the existing resource group and subnet named app.
    6. Create the necessary input variables and terraform.tfvars file.
    7. Add an output to display the subnet ID.
    8. Deploy the configuration and verify the correct output is displayed in the terminal.
  2. Challenge

    Deploy an Azure VM using the Virtual Machine Module

    In this objective, you will use the Azure Virtual Machine Module to deploy an Azure VM to the existing subnet. The VM will have a public IP address and will load a web application using the custom_data parameter.

    1. Add a TLS private key and Azure public IP address to the configuration
    2. Add a custom_data.tpl file with the linked contents from the course repository.
    3. Add the virtual machine module using the following values:
      • image_os: "linux"
      • os_simple: "UbuntuServer"
      • size: "Standard_F2"
    4. Set the custom_data argument to a value that uses the templatefile function and the provided custom_data.tpl file.
    5. Add the necessary input variables and use 80 for the application port.
    6. Add an output for the public IP address of the virtual machine.
    7. Initialize the configuration to add the virtual-machine module and TLS provider.
    8. Validate and deploy the configuration.
  3. Challenge

    Add a Network Security Group to the VM

    In this objective, you will add a Network Security Group (NSG) and NSG rule to allow traffic to the application port defined for the virtual machine. Then associate the NSG with the virtual machine's network interface.

    1. Add the azurerm_network_security_group and azurerm_network_security_rule resources to your configuration. The rule should allow traffic from anywhere to reach the application port over Tcp.
    2. Add a azurerm_network_interface_security_group_association resource to associate the NSG with the network interface of the virtual machine.
    3. Validate and deploy the configuration.
    4. Verify that you can reach the website at the public IP address and port.

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