Skip to content

melvinlee/terraform-az-vm-windows

Repository files navigation

Create Azure VM

Reference the module to a specific version (recommended):

module "virtual_machine" {
    source = "git://github.com/melvinlee/terraform-az-vm-windows.git?ref=v0.1"

    name                = var.name
    location            = var.location
    resource_group_name = var.resource_group_name
    ...
}

Or get the latest version

source = "git://github.com/melvinlee/terraform-az-vm-windows.git?ref=latest"

Parameters

name

variable "name" {
  type        = string
  description = "(Required) Specifies the name of the Virtual Machine. Changing this forces a new resource to be created."
}

resource_group_name

variable "resource_group_name" {
  type        = string
  description = "(Required) Specifies the name of the Resource Group in which the Virtual Machine should exist. Changing this forces a new resource to be created."
}

location

variable "location" {
  type        = string
  description = "(Required) Specifies the Azure Region where the Virtual Machine exists. Changing this forces a new resource to be created."
}

subnet_id

variable "subnet_id" {
  type        = string
  description = "(Required) Reference to a subnet in which this Virtual Machine has been created."
}

image

variable "image" {
  type        = map(string)
  description = "(Optional) To provision vm from an Azure Platform Image."
  default = {
    publisher = "MicrosoftWindowsDesktop"
    offer     = "Windows-10"
    sku       = "rs4-pro"
    version   = "latest"
  }
}

os_profile_windows_config

variable "os_profile_windows_config" {
  type        = map(string)
  description = "(Optional) To configure windows profile."
  default = {
    enable_automatic_upgrades = true
    provision_vm_agent        = true                      # Required VM Agent to execute Azure virtual machine extensions.
    timezone                  = "Singapore Standard Time" # Specifies the time zone of the virtual machine, the possible values are defined http://jackstromberg.com/2017/01/list-of-time-zones-consumed-by-azure/
  }
}

Example: to disable azure vm agent provisioning and automatic_upgrades

 os_profile_windows_config = {
    enable_automatic_upgrades = false
    provision_vm_agent        = false
  }

vm_size

variable "vm_size" {
  type        = string
  description = "(Optional) Specifies the size of the Virtual Machine."
  default     = "Standard_D4s_v3"
}

fqdn

variable "fqdn" {
  type        = string
  description = "(Required) FQDN"
}

admin_username

variable "admin_username" {
  type        = string
  description = "(Required) OS admin name for remote access."
}

admin_password

variable "admin_password" {
  type        = string
  description = "(Required) OS admin password for remote access."
}

boot_diagnostics

variable "boot_diagnostics" {
  description = "(Optional) Enable or Disable boot diagnostics"
  default     = true
}

tags

variable "tags" {
  description = "(Required) Map of tags for the deployment"
}

Output

Contribute

Pull requests are welcome to evolve this module and integrate new features.