Hi there
in this post I’m covering Azure & Terraform series today I’m continuing to use the previous vars.tf file which we used to declare all variables for our main.tf file to standardize our Azure through Terraform scripts.
Before we continue check your Terraform version running terraform –versionĀ
Quick review
- download Terraform from https://www.terraform.io/downloads.html
- edit your Windows PATH variable to point to your terraform main folder (I have a main folder for Azure deployments with a folder on C:\TERRAFORM\ where I extract my Terraform downloaded file into)
- quick commands
- az login
- terraform init
- terraform plan -out myplanName
- terraform apply myplanName
- follow up your console output to check for any warnings, errors and its deployment
- terraform destroy
Now you’re ready to continue
download main.tf for this exercise
changes for this exercise
- removed variable “admin_password” from vars.tf file
- declared data and output variables to capture:
- the vm public ip address
- admin user name (case sensitve)
- admin password (randomly generated on main.tf)
- OK SKU
This main.tf will create the following using variables from vars.tf
- azure resource group named MyTerraform6
- region (location): eastus
- azure VNET named myTFVnet
- azure subnet #1 named myTFSubnet
- azure ubuntu vm 1804 LTS named myTFVM
- azure public ip for the ubuntu vm named myTFPublicIP
- azure nsg with firewall rule allowing ssh tcp port 22 to the vm through its public ip named myTFNSG
- vm admin user named: adminuser
- random vm password: ******
- prefix for all variables replacing the my*azure resource identifier* , where all azure resources to be created under MyTerraform6 azure resource group.
admin_password = i46iE:yr-GqYy_!#
admin_user = Adminuser
os_sku = 18.04-LTS
public_ip_address = 40.87.107.232
Previous Article
Check my Github repository
References
https://learn.hashicorp.com/terraform/azure/variables_az
Thanks,