Any resource we create in Azure need to be part of Resource group. So we will write-up a very basic code to create a Azure Resource group. Below is our sample code to create the resource group “Demo-RG” in “eastus” location.
terraform { required_providers { azurerm = { source = "hashicorp/azurerm" version = "~> 3.0.2" } } required_version = ">= 1.1.0" } provider "azurerm" { features {} } resource "azurerm_resource_group" "DemoRG" { name = "Demo-RG" location = "eastus" }
Next save the above text onto a .tf file e.g. main.tf . Browse to terminal and login to your Azure tenant using cmdlts az login.
Once logged in then run below cmdlts
Terraform.exe init Terraform.exe plan Terraform.exe apply
Once all completed login to your azure tenant and you should be able to see resource group Demo-RG created