I have recently been working my way through the Microsoft documentation on Terraform .The first project I took on was “Create an Azure Virtual Machine scale set”. Here is what I have learned, the challenges I faced, and how I overcame them.
What I have learned
- How to install Terraform (see previous blog)
- How to use VS Code to create and edit .tf files — Install the Terraform Visual Studio Code Extension .
- How to authenticate to Azure with Terraform
- Terraform syntax and how to understand it
- How to use the Terraform Registry to find example code
- Terraform commands — terraform init, terraform plan , terraform apply and terraform destroy
Challenges I faced and how I overcame them
- Understanding the Terraform syntax rather than just copying and pasting from the tutorial
I utilised various sources to help — John Savills Youtube Video “Using Terraform on Azure”, Cloudskills.io Terraform on Azure course and Terraforms Get Started documentation .
Example
Resource blocks are used to define infrastructure , below is a block to create a resource group. This block has two labels 1. the resource type in this case a resource group “azurerm_resource_group” 2. the label for the block .
- Formatting my code so it looked good
I did a Google and found out about the terraform fmt command
- Making it stick
At first I was just copying and pasting code from the Terraform Registry but typing it out manually has really helped me to understand it.