Wednesday, January 19, 2022

Configure Storage account in Azure using Terraform

Description: Here I have explained, How to setup Storage Account in Azure using Terraform

  • Create terraform project file for storage account as follow and save as Storage.tf

variable "storage_account_name" { type=string default="servertechstorage" } variable "resource_group_name" { type=string default="DevOPS1" } provider "azurerm"{ version = "=2.0" subscription_id = "XXXXX-XXXX-XXXX-XXX-XXXXXX" tenant_id = "XXXXXX-XXXX-XXXX-XXXX-XXXXXX"
features {} } resource "azurerm_resource_group" "grp" { name = var.resource_group_name location = "East US" } resource "azurerm_storage_account" "store" { name = var.storage_account_name resource_group_name = azurerm_resource_group.grp.name location = azurerm_resource_group.grp.location account_tier = "Standard" account_replication_type = "LRS" }


Here,
Resource Group Name: DevOPS1
StorageAccount Name:  servertechstorage
Subscription_id:            Subscription id of Your Azure Account 
tenant_id:                       Tenant ID of Your Azure Account 

You can add or remove variables and values as per your requirement

  • Open Azure Cloud Shell from the Azure Portal





  • Verify Terraform version by using terraform --version command 









  • Upload storage.tf file in Azure Cloud shell 


  • After Upload the file run terraform init command for project initialization 














  • Run terraform plan -out PlanName create a plan 




















  • Run terraform apply to apply/Run the project 










  • Once the process will be completed you will find the storage account in the Azure portal


No comments:

Post a Comment