0
0
Terraformcloud~30 mins

Azure Storage backend in Terraform - Mini Project: Build & Apply

Choose your learning style9 modes available
Azure Storage backend
📖 Scenario: You are setting up Terraform to store its state files securely in Azure Storage. This helps teams collaborate safely and keeps your infrastructure state consistent.
🎯 Goal: Create a Terraform configuration that uses an Azure Storage Account as the backend to store the Terraform state file.
📋 What You'll Learn
Create a resource group named exactly tfstate-rg
Create a storage account named exactly tfstateaccount
Create a storage container named exactly tfstatecontainer
Configure the Terraform backend to use the Azure Storage Account with the correct resource group, storage account, and container names
💡 Why This Matters
🌍 Real World
Storing Terraform state files in Azure Storage is a common practice in real projects to enable collaboration and state locking.
💼 Career
Understanding how to configure remote backends in Terraform is essential for cloud engineers and DevOps professionals working with Azure.
Progress0 / 4 steps
1
Create the Azure resource group
Write Terraform code to create a resource group named tfstate-rg in the eastus location. Use the resource type azurerm_resource_group and name the resource tfstate_rg.
Terraform
Need a hint?

Use resource "azurerm_resource_group" "tfstate_rg" with name = "tfstate-rg" and location = "eastus".

2
Create the Azure storage account
Add Terraform code to create a storage account named tfstateaccount in the resource group tfstate-rg. Use the resource type azurerm_storage_account and name the resource tfstate_sa. Set account_tier to Standard and account_replication_type to LRS.
Terraform
Need a hint?

Use resource "azurerm_storage_account" "tfstate_sa" with the exact name and link to the resource group.

3
Create the storage container
Add Terraform code to create a storage container named tfstatecontainer inside the storage account tfstateaccount. Use the resource type azurerm_storage_container and name the resource tfstate_container. Set the container_access_type to private.
Terraform
Need a hint?

Use resource "azurerm_storage_container" "tfstate_container" with the exact container name and link to the storage account.

4
Configure the Terraform backend
Add the terraform block to configure the backend to use Azure Storage. Set storage_account_name to tfstateaccount, container_name to tfstatecontainer, and resource_group_name to tfstate-rg. Use key as terraform.tfstate.
Terraform
Need a hint?

Use the terraform block with backend "azurerm" and set the exact names for resource group, storage account, container, and key.