GitHunt
KO

kogunlowo123/terraform-azure-virtual-machine-linux

Terraform module for Azure Linux VMs with managed disks, extensions, and availability zones

terraform-azure-virtual-machine-linux

Production-ready Terraform module for Azure Linux Virtual Machines with managed disks, SSH key authentication, Azure Monitor Agent, custom extensions, and backup integration.

Architecture

flowchart TB
    subgraph VM["Azure Linux Virtual Machine"]
        direction TB
        LVM[Linux VM]
        OS[OS Disk - Encrypted]
        SSH[SSH Key Auth]
        ID[Managed Identity]
    end

    subgraph Storage["Data Disks"]
        D1[Data Disk 1]
        D2[Data Disk 2]
    end

    subgraph Extensions["Extensions"]
        AMA[Azure Monitor Agent]
        CST[Custom Extensions]
    end

    subgraph Backup["Backup"]
        RSV[Recovery Services Vault]
        POL[Backup Policy]
    end

    subgraph Monitoring["Monitoring"]
        DCR[Data Collection Rules]
        LA[Log Analytics]
    end

    LVM --> Storage
    LVM --> Extensions
    AMA --> Monitoring
    LVM --> Backup

    style VM fill:#0078D4,color:#fff
    style Storage fill:#1A73E8,color:#fff
    style Extensions fill:#3F8624,color:#fff
    style Backup fill:#DD344C,color:#fff
    style Monitoring fill:#FF9900,color:#fff

Features

  • SSH key authentication with password auth disabled by default
  • Managed OS disk with configurable size, type, and encryption
  • Additional data disks with independent configurations
  • Azure Monitor Agent with data collection rule association
  • Custom VM extensions support
  • Boot diagnostics
  • SystemAssigned and UserAssigned managed identity
  • Azure Backup integration with Recovery Services Vault
  • Availability zone placement

Usage

Basic

module "linux_vm" {
  source = "github.com/kogunlowo123/terraform-azure-virtual-machine-linux"

  name                 = "my-linux-vm"
  resource_group_name  = azurerm_resource_group.this.name
  location             = "East US"
  admin_username       = "azureuser"
  admin_ssh_public_key = file("~/.ssh/id_rsa.pub")
  network_interface_ids = [azurerm_network_interface.this.id]

  tags = { Environment = "production" }
}

Requirements

Name Version
terraform >= 1.5.0
azurerm >= 3.80.0

Inputs

Name Description Type Default Required
name VM name string n/a yes
resource_group_name Resource group name string n/a yes
location Azure region string n/a yes
size VM size string "Standard_D2s_v5" no
admin_username Admin username string "azureuser" no
admin_ssh_public_key SSH public key string n/a yes
network_interface_ids NIC IDs list(string) n/a yes
data_disks Map of data disk configs map(object) {} no
enable_azure_monitor_agent Enable AMA bool true no
enable_backup Enable backup bool false no

Outputs

Name Description
vm_id The ID of the VM
vm_name The name of the VM
private_ip_address The private IP
public_ip_address The public IP
identity The managed identity block
data_disk_ids Map of data disk IDs

License

MIT Licensed. See LICENSE for details.

Languages

HCL100.0%

Contributors

Latest Release

v1.0.0March 7, 2026
MIT License
Created March 7, 2026
Updated March 16, 2026