Deploying VMs is the primary target for almost all attempts at automation. Terraform provides a much more human-readable syntax than that of an ARM template, and allows for the creation of any prerequisites you may want, or need without having to jump around multiple portal screens. In this hands-on lab, we will take what we’ve done in the previous labs and add in the creation of a NIC and a marketplace Ubuntu VM. Additionally, we will create a Boot Diagnostics storage account to support the use of the serial console, providing a quick way to test the VM’s deployment.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Set Up the Command Line Interface (CLI)
- Open the CLI.
- Select Bash at the prompt.
- Click Show Advanced Settings. Both the Resource Group and Storage Account should be pre-selected with the lab generated values.
- In the File share section, choose the Create new radio button and enter console.
- Click the Attach Storage button.
- Once the command prompt is initialized, proceed to Task 2.
- Deploy a Ubuntu VM
- Use the code block found in the Additional Information and Resources section to create a
test.tf
file and upload it to the CLI. - In the (resource
"azurerm_storage_account" "lab"
) declaration, you’ll need to edit theresource_group_name
value with the name generated by the lab. The"provider"
statement has been added to the code, so you won’t need to create amain.tf
file to deploy the storage account. - Once the file has been uploaded, run
terraform init
. - Run
terraform plan
and review the output to confirm that Terraform will create the desired resource. Green plus signs will indicate the resources that need to be added. - Run
terraform apply
, answering yes to the prompt to continue. - Once Terraform completes the deployment, check the Azure Portal to confirm.
- Use the code block found in the Additional Information and Resources section to create a