Basic-Create Azure Resource Group using Terraform

Rajkumar R
3 min readMar 17, 2022

In this story we can quickly understand the terraoform first basic steps to design our resource and deploy and destroy.

Step1: Install Terraform to your local machine/ system which you are working and to implement IaC code to deploy resource and check version as below:

Step2: Make sure you are in the directory where **.tf file which declaratively planning to deploy resource in cloud providers, here it is Azure Provider

Main.tf under the directory and below are sample file to deploy resource group and with Tags

Step3: Make initializaion of the directory using the command “terraform init

It will download the binaries and plugins which used to deploy the resource to the Azure providers under the directory which we executed the terraform init command.

When the check the directory post this command you can see the additional files are added.

Step4: Now you validate the .tf file which is good using the command terraform validate

Step5: Now you can execute the plan command to check what are the changes going to do in the remote Azure Cloud by using the command terraform plan

Post executing the plan command and now you can see the what changes which is going to happen in remote cloud and here it is going to create Azure Resource group

Step6: Now post the validation of plan and you can execute the command terraform applyso it will start creating mentioned resource in the .tf file and before it make the change it will ask our confirmation like below:

Post confirmation “yes” and it will start creating resource in the Azure

Tips: You can also use the command terraform apply --auto-approveto create resource, it will not ask any confirmation and it directly execute the file post running the command.

Creating resource group in remote Azure CLoud

Step7: You can delete the resource whcih we created using the destroy command and it will destroy the resource which created as part of .tf file

terraform destroy

terraoform destroy and seeking confirmation before deleting the resource
Destroyed the resource which we created using main.tf file

Hope this basic will helped to understand the terraform overview!

--

--

Rajkumar R

System Administrator, Microsoft certified - Azure Administrator, Devops