TerraformTerraform on AWS: A Complete Beginner's Guide
A beginner-friendly Terraform AWS guide with provider setup, S3 bucket, EC2 instance, VPC networking, remote state, and best practices for safe deployments.
Terraform
A beginner-friendly Terraform Azure guide with provider setup, resource groups, VNets, VMs, and remote state. Step-by-step with code examples.

Install Terraform, log in with az login, configure the azurerm provider with an empty features {} block, and run terraform init && terraform plan && terraform apply. Azure resources need a Resource Group first — everything goes inside one.
# Install Azure CLI
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
az login
az account show # Verify subscription
# Install Terraform
terraform versionterraform {
required_version = ">= 1.5"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.90"
}
}
}
provider "azurerm" {
features {} # Required — even if empty
}Every Azure resource lives in a Resource Group:
resource "azurerm_resource_group" "main" {
name = "terraform-demo-rg"
location = "East US"
}terraform init
terraform plan
terraform applyresource "azurerm_virtual_network" "main" {
name = "demo-vnet"
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.main.location
resource_group_name = azurerm_resource_group.main.name
}
resource "azurerm_subnet" "app" {
name = "app-subnet"
resource_group_name = azurerm_resource_group.main.name
virtual_network_name = azurerm_virtual_network.main.name
address_prefixes = ["10.0.1.0/24"]
}resource "azurerm_network_interface" "web" {
name = "web-nic"
location = azurerm_resource_group.main.location
resource_group_name = azurerm_resource_group.main.name
ip_configuration {
name = "internal"
subnet_id = azurerm_subnet.app.id
private_ip_address_allocation = "Dynamic"
}
}
resource "azurerm_linux_virtual_machine" "web" {
name = "web-vm"
resource_group_name = azurerm_resource_group.main.name
location = azurerm_resource_group.main.location
size = "Standard_B2s"
admin_username = "azureuser"
network_interface_ids = [azurerm_network_interface.web.id]
admin_ssh_key {
username = "azureuser"
public_key = file("~/.ssh/id_rsa.pub")
}
os_disk {
caching = "ReadWrite"
storage_account_type = "Standard_LRS"
}
source_image_reference {
publisher = "Canonical"
offer = "0001-com-ubuntu-server-jammy"
sku = "22_04-lts"
version = "latest"
}
}# Create storage for state
az group create --name terraform-state-rg --location eastus
az storage account create --name tfstatemycompany \
--resource-group terraform-state-rg --sku Standard_LRS
az storage container create --name tfstate --account-name tfstatemycompanyterraform {
backend "azurerm" {
resource_group_name = "terraform-state-rg"
storage_account_name = "tfstatemycompany"
container_name = "tfstate"
key = "demo.terraform.tfstate"
}
}| Azure Concept | Purpose | Terraform Resource |
|---|---|---|
| Resource Group | Container for resources | azurerm_resource_group |
| Virtual Network | Networking | azurerm_virtual_network |
| Subnet | Network segment | azurerm_subnet |
| NSG | Firewall rules | azurerm_network_security_group |
| VM | Compute | azurerm_linux_virtual_machine |
| Storage Account | Blob/file storage | azurerm_storage_account |
terraform destroy # Removes all resourcesTerraform on Azure follows the same init → plan → apply workflow as other clouds. Start with a Resource Group, add networking, then compute. Use Azure Blob Storage for remote state. The azurerm provider requires a features {} block — even if empty.
TerraformA beginner-friendly Terraform AWS guide with provider setup, S3 bucket, EC2 instance, VPC networking, remote state, and best practices for safe deployments.
TerraformA beginner-friendly Terraform GCP guide with provider setup, service accounts, GCS buckets, Compute Engine VMs, and networking. Step-by-step with code examples.
Cloud ComputingConfigure Azure Monitor, Log Analytics, and alerts with Terraform for comprehensive cloud observability.
Cloud ComputingDeploy Azure Container Registry and Container Instances with Terraform for lightweight container workloads.