Hi there

At this post series we’ll cover the how to create an Azure Resource Group, VNET (Virtual Network) with subnets and 01 Linux VM with Public IP address accessible from internet on SSH (TCP Port 22)

    1. Access your Visual Studio Code
    2. Create a new Folder where your project will be stored
    3. Have your Azure subscription credentials ready
    4. Log on your Azure subscription from the Visual Studio Code Terminal
    5. Create your main.tf file and save it with empty content
    6. Here it’s how your screen should be like

  1. Use the following example to create your 1st Azure Resource Group with your Azure Resources within it.
    #Provider
    
    provider "azurerm" {
    
      features {}
    
    }
    
    #Azure Resource Group
    
    resource "azurerm_resource_group" "terraform" {
    
      name     = "terraform"
    
      location = "canadacentral"
    
      }
    
  2. You’ll see an error on this deployment because my Azure Subscription has a Policy enforcement to allow resources only in Canada Central location / region.
  3. Fix the location at the main.tf file and proceed with:
    1. terraform init
    2. terraform plan– you can also try the following: terraform plan -out myplan2
      – this saves your current plan to myplan2 file
    3. terraform apply (you need to confirm the operation with YES)
      – or you can apply the saved plan: terraform apply myplan2
      – this apply your saved myplan2 to your azure subscription
    4. check the output to make sure your deployment run ok
  • Test your access to the new deployed Resource Group in Azure
    1. Open Chrome (with the auto refresh plugin) on the Azure Portal website at Azure Resources tab to see when the Azure Resource Group you’ve created shows up
  • Keep this main.tf for the next article.

Thanks,

Thiago Beier
TwitterLinkedInFacebookRSS