azurenoops / terraform-azurerm-overlays-virtual-machine

Terraform module overlay to deploy single or multiple SCCA compliant Virtual Machines of Linux or Windows with optional features to be used with Azure NoOps.
MIT License
1 stars 1 forks source link

Azure Virtual Machines Overlay Terraform Module

Changelog Notice MIT License TF Registry

This Overlay Terraform module can deploy Azure Windows or Linux virtual machines with support for Public IP, proximity placement group, Availability Set, boot diagnostics, data disks, and Network Security Group. It supports existing ssh keys and produces ssh key pairs for Linux VMs as needed. If you do not provide a special password for Windows VMs it generates random passwords. This module can be utilized in a SCCA compliant network.

This module requires you to use an existing NSG group. To enable this functionality, replace the input 'existing_network_security_group_name' with the current NSG group's valid resource name and you can use NSG inbound rules from the module.

SCCA Compliance

This module can be SCCA compliant and can be used in a SCCA compliant Network. Enable private endpoints and SCCA compliant network rules to make it SCCA compliant.

For more information, please read the SCCA documentation.

Contributing

If you want to contribute to this repository, feel free to to contribute to our Terraform module.

More details are available in the CONTRIBUTING.md file.

Resources Supported

Module Usage

# Azurerm provider configuration
provider "azurerm" {
  features {}
}

module "mod_virtual_machine" {
  source  = "azurenoops/overlays-virtual-machine/azurerm"
  version = "x.x.x"

  # Resource Group, location, VNet and Subnet details
  existing_resource_group_name = azurerm_resource_group.linux-vm-rg.name
  location                     = var.location
  deploy_environment           = var.deploy_environment
  org_name                     = var.org_name
  workload_name                = var.workload_name

  # Lookup Network Information for VM deployment
  existing_virtual_network_resource_group_name = azurerm_virtual_network.linux-vnet.resource_group_name
  existing_virtual_network_name                = azurerm_virtual_network.linux-vnet.name
  existing_subnet_name                         = azurerm_subnet.linux-snet.name
  existing_network_security_group_name         = azurerm_network_security_group.linux-nsg.name

  # This module supports a variety of pre-configured Linux and Windows distributions.
  # See the README.md file for more pre-defined Ubuntu, Centos, and RedHat images.
  # If you use gen2 distributions, please use gen2 images with supported VM sizes.
  # To generate a random admin password, specify 'disable_password_authentication = false' 
  # To use your own password, specify a valid password with the 'admin_password' parameter 
  # To produce an SSH key pair, specify 'generate_admin_ssh_key = true'
  # To use an existing key pair, set 'admin_ssh_key_data' to the path of a valid SSH public key.  
  os_type                         = "linux"
  linux_distribution_name         = "ubuntu2004"
  virtual_machine_size            = "Standard_B2s"
  disable_password_authentication = false
  admin_username                  = "azureadmin"
  admin_password                  = "P@$$w0rd1234!"
  instances_count                 = 2 # Number of VM's to be deployed

  # The proximity placement group, Availability Set, and assigning a public IP address to VMs are all optional.
  # If you don't wish to utilize these arguments, delete them from the module. 
  enable_proximity_placement_group   = true
  enable_vm_availability_set         = true
  private_ip_address_allocation_type = "Static" # Static or Dynamic
  private_ip_address                 = ["10.0.1.36", "10.0.1.37"]

  # Network Security group port definitions for each Virtual Machine 
  # NSG association for all network interfaces to be added automatically.
  # If 'existing_network_security_group_name' is supplied, the module will use the existing NSG.
  nsg_inbound_rules = [
    {
      name                   = "ssh"
      destination_port_range = "22"
      source_address_prefix  = "*"
    },
    {
      name                   = "http"
      destination_port_range = "80"
      source_address_prefix  = "*"
    },
  ]

  # Boot diagnostics are used to troubleshoot virtual machines by default. 
  # To use a custom storage account, supply a valid name for'storage_account_name'. 
  # Passing a 'null' value will use a Managed Storage Account to store Boot Diagnostics.
  enable_boot_diagnostics = true

  # Attach a managed data disk to a Windows/Linux virtual machine. 
  # Storage account types include: #'Standard_LRS', #'StandardSSD_ZRS', #'Premium_LRS', #'Premium_ZRS', #'StandardSSD_LRS', #'UltraSSD_LRS' (UltraSSD_LRS is only accessible in regions that support availability zones).
  # Create a new data drive - connect to the VM and execute diskmanagement or fdisk.
  data_disks = [
    {
      name                 = "disk1"
      disk_size_gb         = 100
      storage_account_type = "StandardSSD_LRS"
    },
    {
      name                 = "disk2"
      disk_size_gb         = 200
      storage_account_type = "Standard_LRS"
    }
  ]

  # AAD Login is used to login to the VM using Azure Active Directory credentials.
  /* aad_login_enabled = true
  aad_login_user_objects_ids = [
    data.azuread_group.vm_users_group.object_id
  ]

  aad_login_admin_objects_ids = [
    data.azuread_group.vm_admins_group.object_id
  ] */

  # (Optional) To activate Azure Monitoring and install log analytics agents 
  # (Optional) To save monitoring logs to storage, specify'storage_account_name'.    
  log_analytics_workspace_id = azurerm_log_analytics_workspace.linux-log.id

  # Deploy log analytics agents on a virtual machine. 
  # Customer id and primary shared key for Log Analytics workspace are required.
  deploy_log_analytics_agent                 = true
  log_analytics_customer_id                  = azurerm_log_analytics_workspace.linux-log.workspace_id
  log_analytics_workspace_primary_shared_key = azurerm_log_analytics_workspace.linux-log.primary_shared_key

  # Adding additional TAG's to your Azure resources
  add_tags = {
    Example = "basic_linux_virtual_machine_using_existing_RG"
  }
}

Pre-Defined Windows and Linux VM Images

By using the linux_distribution_name or windows_distribution_name arguments with this module, you can deploy pre-defined Windows or Linux images.

OS type Available Pre-defined Images
Linux ubuntu2004, ubuntu2004-gen2, ubuntu1904, ubuntu1804, ubuntu1604, centos75, centos77, centos78-gen2, centos79-gen2, centos81, centos81-gen2, centos82-gen2, centos83-gen2, centos84-gen2 coreos, rhel78, rhel78-gen2, rhel79, rhel79-gen2, rhel81, rhel81-gen2, rhel82, rhel82-gen2, rhel83, rhel83-gen2, rhel84, rhel84-gen2, rhel84-byos, rhel84-byos-gen2
Windows windows2012r2dc, windows2016dc, windows2016dccore, windows2019dc, windows2019dccore, windows2019dccore-g2, windows2019dc-gensecond, windows2019dc-gs, windows2019dc-containers, windows2019dc-containers-g2
MS SQL 2017 mssql2017exp, mssql2017dev, mssql2017std, mssql2017ent
MS SQL 2019 mssql2019dev, mssql2019std, mssql2019ent
MS SQL 2019 Linux (RHEL8) mssql2019ent-rhel8, mssql2019std-rhel8, mssql2019dev-rhel8
MS SQL 2019 Linux (Ubuntu) mssql2019ent-ubuntu1804, mssql2019std-ubuntu1804, mssql2019dev-ubuntu1804, mssql2019ent-ubuntu2004, mssql2019std-ubuntu2004, mssql2019dev-ubuntu2004
MS SQL 2019 Bring your own License (BOYL) mssql2019ent-byol, mssql2019std-byol

Custom Virtual Machine images

If the pre-defined Windows or Linux variations are insufficient, you can supply a custom image by configuring the 'custom_image' option with appropriate values. Bootstrapping configurations such as preloading apps, application setups, and other OS customizations can all be done with custom images. More information can be found here.(https://docs.microsoft.com/en-us/azure/virtual-machines/linux/tutorial-custom-images)

Licensed Marketplace Images

For some Marketplace images you will need to provide a 'custom_image_plan' object and accept the license terms. For more information on the please see the plan block documentation at https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_virtual_machine#plan.

Before using licensed Marketplace image, you may need to accept legal plan terms using the Powershell command found at https://learn.microsoft.com/en-us/cli/azure/vm/image/terms?view=azure-cli-latest#az-vm-image-terms-accept. The response from this command will provide the values needed for the custom_image_plan object.

module "virtual-machine" {
  source  = "azurenoops/overlays-virtual-machine/azurerm"
  version = "x.x.x"

# .... omitted

  os_flavor               = "linux"
  linux_distribution_name = "ubuntu2004"
  virtual_machine_size    = "Standard_B2s"
  generate_admin_ssh_key  = true
  instances_count         = 2

 os_type = "linux"
  custom_image = {
    publisher = "paloaltonetworks"
    offer     = "panorama"
    sku       = "byol"
    version   = "latest"
  }

  custom_image_plan = {
    publisher = "paloaltonetworks"
    product   = "panorama"
    name      = "byol"
  }

# .... omitted 

}

Network Security Groups

By default, network security groups are attached to Network Interface and allow just necessary traffic while blocking all others (deny-all rule). In this Terraform module, use nsg_inbound_rules to construct a Network Security Group (NSG) for a network interface and allow it to add additional rules for inbound flows.

VirtualNetwork, AzureLoadBalancer, and Internet are service tags rather than IP addresses in the Source and Destination columns. Any in the protocol column includes TCP, UDP, and ICMP. You can choose TCP, UDP, ICMP, or * when establishing a rule. In the Source and Destination columns, 0.0.0.0/0 represents all addresses.

You cannot remove the default rules, but you can override them by creating rules with higher priorities.

module "virtual-machine" {
  source  = "azurenoops/overlays-virtual-machine/azurerm"
  version = "x.x.x"

# .... omitted

  os_flavor               = "linux"
  linux_distribution_name = "ubuntu2004"
  virtual_machine_size    = "Standard_B2s"
  generate_admin_ssh_key  = true
  instances_count         = 2

  existing_network_security_group_name = azurerm_network_security_group.linux-nsg.name
  nsg_inbound_rules = [
    {
      name                   = "ssh"
      destination_port_range = "22"
      source_address_prefix  = "*"
    },

    {
      name                   = "http"
      destination_port_range = "80"
      source_address_prefix  = "*"
    },
  ]

# .... omitted

}

Using existing Network Resource Groups

On occasion, you may need to deploy resources to diffent resource group but use the existing network resource group. This module allows you to use an existing network resource group by setting the input existing_virtual_network_resource_group_name to the name of the network resource group.


```terraform
data "azurerm_virtual_network" "example" {
  name                = "nsg_mgnt_vnet_in"
  resource_group_name = "vnet-shared-hub-westeurope-001"
}

data "azurerm_network_security_group" "example" {
  name                = "nsg_mgnt_subnet_in"
  resource_group_name = "vnet-shared-hub-westeurope-001"
}

module "virtual-machine" {
   source  = "azurenoops/overlays-virtual-machine/azurerm"
  version = "x.x.x"

# .... omitted for bravity

  os_flavor               = "linux"
  linux_distribution_name = "ubuntu2004"
  virtual_machine_size    = "Standard_B2s"
  generate_admin_ssh_key  = true
  instances_count         = 2

  # Network Security group port allow definitions for each Virtual Machine
  # NSG association to be added automatically for all network interfaces.  
  existing_virtual_network_resource_group_name = data.azurerm_virtual_network.example.resource_group_name
  existing_network_security_group_name         = data.azurerm_network_security_group.example.name

# .... omitted for bravity

}

Using existing Network Security Groups

To maintain capabilities, enterprise environments require the utilization of pre-existing NSG groups. This module facilitates the use of existing network security groups. Set the input existing_network_security_group_name to use a valid NSG resource name.

data "azurerm_network_security_group" "example" {
  name                = "nsg_mgnt_subnet_in"
  resource_group_name = "vnet-shared-hub-westeurope-001"
}

module "virtual-machine" {
   source  = "azurenoops/overlays-virtual-machine/azurerm"
  version = "x.x.x"

# .... omitted for bravity

  os_flavor               = "linux"
  linux_distribution_name = "ubuntu2004"
  virtual_machine_size    = "Standard_B2s"
  generate_admin_ssh_key  = true
  instances_count         = 2

  # Network Security group port allow definitions for each Virtual Machine
  # NSG association to be added automatically for all network interfaces.  
  existing_network_security_group_name = data.azurerm_network_security_group.example.name

# .... omitted for bravity

}

Recommended naming and tagging conventions

Using tags to properly organize your Azure resources, resource groups, and subscriptions into a taxonomy. Each tag is made up of a name and a value pair. For example, you can apply the term Environment and the value Production to all production resources. See Resource name and tagging choice guide for advice on how to apply a tagging strategy.

Important : For operations, tag names are case-insensitive. A tag with a tag name is updated or retrieved, independent of casing. The resource provider, on the other hand, may preserve the casing you supply for the tag name. Cost reports will show that casing. The case of tag values is important.

An effective naming convention creates resource names by incorporating vital resource information into the name. A public IP resource for a production SharePoint workload, for example, is named pip-sharepoint-prod-westus-001 using these recommended naming conventions.

Requirements

Name Version
terraform >= 1.3
azurenoopsutils ~> 1.0.4
azurerm ~> 3.22
random >= 3.1.0
tls >= 3.1.0

Providers

Name Version
azurenoopsutils ~> 1.0.4
azurerm ~> 3.22
random >= 3.1.0
tls >= 3.1.0

Modules

Name Source Version
mod_azregions azurenoops/overlays-azregions-lookup/azurerm ~> 1.0.0
mod_scaffold_rg azurenoops/overlays-resource-group/azurerm ~> 1.0.1

Resources

Name Type
azurerm_availability_set.aset resource
azurerm_backup_protected_vm.backup resource
azurerm_linux_virtual_machine.linux_vm resource
azurerm_managed_disk.data_disk resource
azurerm_network_interface.nic resource
azurerm_network_interface_security_group_association.nsgassoc resource
azurerm_network_security_group.nsg resource
azurerm_network_security_rule.nsg_rule resource
azurerm_proximity_placement_group.appgrp resource
azurerm_public_ip.pip resource
azurerm_virtual_machine_data_disk_attachment.data_disk resource
azurerm_virtual_machine_extension.omsagentlinux resource
azurerm_virtual_machine_extension.omsagentwin resource
azurerm_windows_virtual_machine.win_vm resource
random_password.passwd resource
tls_private_key.rsa resource
azurenoopsutils_resource_name.avset data source
azurenoopsutils_resource_name.computer_windows data source
azurenoopsutils_resource_name.disk data source
azurenoopsutils_resource_name.nic data source
azurenoopsutils_resource_name.nsg data source
azurenoopsutils_resource_name.ppg data source
azurenoopsutils_resource_name.pub_ip data source
azurenoopsutils_resource_name.vm_linux data source
azurenoopsutils_resource_name.vm_windows data source
azurerm_client_config.current data source
azurerm_resource_group.rgrp data source
azurerm_storage_account.storeacc data source
azurerm_subnet.snet data source
azurerm_virtual_network.vnet data source

Inputs

Name Description Type Default Required
additional_nic_configuration The configuration information used when a second NIC needs to be added to the VM.
object({
subnet_id = string
private_ip_address = string
})
null no
add_tags Extra tags to set on each created resource. map(string) {} no
additional_unattend_content The XML formatted content that is added to the unattend.xml file for the specified path and component. any null no
additional_unattend_content_setting The name of the setting to which the content applies. Possible values are AutoLogon and FirstLogonCommands any null no
admin_password The Password which should be used for the local-administrator on this Virtual Machine any null no
admin_ssh_key_data specify the path to the existing SSH key to authenticate Linux virtual machine any null no
admin_username The username of the local administrator used for the Virtual Machine. string "azureadmin" no
application_gateway_backend_pool_id Id of the Application Gateway Backend Pool to attach the VM. string null no
attach_application_gateway True to attach this VM to an Application Gateway bool false no
attach_load_balancer True to attach this VM to a Load Balancer bool false no
backup_policy_id Backup policy ID from the Recovery Vault to attach the Virtual Machine to (value to null to disable backup) string null no
create_resource_group Controls if the resource group should be created. If set to false, the resource group name must be provided. Default is false. bool false no
custom_computer_name Custom name for the Windows Virtual Machine Hostname. vm_name if not set. string "" no
custom_data Base64 encoded file of a bash script that gets run once by cloud-init upon VM creation any null no
custom_dcr_name Custom name for Data collection rule association string null no
custom_image Provide the custom image to this module if the default variants are not sufficient
map(object({
publisher = string
offer = string
sku = string
version = string
}))
null no
custom_image_plan Provide the custom image plan to this module if the custom image selected is a licensed Marketplace image
object({
name = string
product = string
publisher = string
})
null no
custom_ipconfig_name Custom name for the IP config of the NIC. Generated if not set. string null no
custom_linux_vm_name Custom name for the Linux Virtual Machine. Generated if not set. string "" no
custom_nic_name Custom name for the NIC interface. Generated if not set. string null no
custom_public_ip_name Custom name for public IP. Generated if not set. string null no
custom_resource_group_name The name of the resource group in which the resources will be created in. If not provided, a new resource group will be created with the name '<org_name>--<workload_name>-rg' string null no
custom_windows_vm_name Custom name for the Windows Virtual Machine. Generated if not set. string "" no
data_disks Managed Data Disks for azure virtual machines
list(object({
name = string
storage_account_type = string
disk_size_gb = number
}))
[] no
dedicated_host_id The ID of a Dedicated Host where this machine should be run on. any null no
default_tags_enabled Option to enable or disable default tags. bool true no
deploy_environment Name of the workload's environnement string n/a yes
deploy_log_analytics_agent Install log analytics agent to windows or linux VM bool false no
disable_password_authentication Should Password Authentication be disabled on this Linux Virtual Machine? Defaults to true. bool true no
disk_encryption_set_id The ID of the Disk Encryption Set which should be used to Encrypt this OS Disk. The Disk Encryption Set must have the Reader Role Assignment scoped on the Key Vault - in addition to an Access Policy to the Key Vault any null no
disk_size_gb The Size of the Internal OS Disk in GB, if you wish to vary from the size used in the image this Virtual Machine is sourced from. any null no
dns_servers List of dns servers to use for network interface list [] no
domain_name_label Label for the Domain Name. Will be used to make up the FQDN. If a domain name label is specified, an A DNS record is created for the public IP in the Microsoft Azure DNS system. any null no
enable_accelerated_networking Should Accelerated Networking be enabled? Defaults to false. bool false no
enable_automatic_updates Specifies if Automatic Updates are Enabled for the Windows Virtual Machine. bool false no
enable_boot_diagnostics Should the boot diagnostics enabled? bool false no
enable_encryption_at_host Should all of the disks (including the temp disk) attached to this Virtual Machine be encrypted by enabling Encryption at Host? bool false no
enable_ip_forwarding Should IP Forwarding be enabled? Defaults to false bool false no
enable_os_disk_write_accelerator Should Write Accelerator be Enabled for this OS Disk? This requires that the storage_account_type is set to Premium_LRS and that caching is set to None. bool false no
enable_proximity_placement_group Manages a proximity placement group for virtual machines, virtual machine scale sets and availability sets. bool false no
enable_public_ip_address Reference to a Public IP Address to associate with the NIC any null no
enable_ultra_ssd_data_disk_storage_support Should the capacity to enable Data Disks of the UltraSSD_LRS storage account type be supported on this Virtual Machine bool false no
enable_vm_availability_set Manages an Availability Set for Virtual Machines. bool false no
existing_network_security_group_id The resource name of existing network security group any null no
existing_resource_group_name The name of the existing resource group to use. If not set, the name will be generated using the org_name, workload_name, deploy_environment and environment variables. string null no
extensions_add_tags Extra tags to set on the VM extensions. map(string) {} no
generate_admin_ssh_key Generates a secure private key and encodes it as PEM. bool false no
instances_count The number of Virtual Machines required. Default is 1. number 1 no
internal_dns_name_label The (relative) DNS Name used for internal communications between Virtual Machines in the same Virtual Network. any null no
key_vault_certificate_secret_url The Secret URL of a Key Vault Certificate, which must be specified when protocol is set to Https any null no
license_type Specifies the type of on-premise license which should be used for this Virtual Machine. Possible values are None, Windows_Client and Windows_Server. string "None" no
linux_distribution_list Pre-defined Azure Linux VM images list
map(object({
publisher = string
offer = string
sku = string
version = string
}))
{
"centos77": {
"offer": "CentOS",
"publisher": "OpenLogic",
"sku": "7.7",
"version": "latest"
},
"centos78-gen2": {
"offer": "CentOS",
"publisher": "OpenLogic",
"sku": "7_8-gen2",
"version": "latest"
},
"centos79-gen2": {
"offer": "CentOS",
"publisher": "OpenLogic",
"sku": "7_9-gen2",
"version": "latest"
},
"centos81": {
"offer": "CentOS",
"publisher": "OpenLogic",
"sku": "8_1",
"version": "latest"
},
"centos81-gen2": {
"offer": "CentOS",
"publisher": "OpenLogic",
"sku": "8_1-gen2",
"version": "latest"
},
"centos82-gen2": {
"offer": "CentOS",
"publisher": "OpenLogic",
"sku": "8_2-gen2",
"version": "latest"
},
"centos83-gen2": {
"offer": "CentOS",
"publisher": "OpenLogic",
"sku": "8_3-gen2",
"version": "latest"
},
"centos84-gen2": {
"offer": "CentOS",
"publisher": "OpenLogic",
"sku": "8_4-gen2",
"version": "latest"
},
"coreos": {
"offer": "CoreOS",
"publisher": "CoreOS",
"sku": "Stable",
"version": "latest"
},
"mssql2019dev-rhel8": {
"offer": "sql2019-rhel8",
"publisher": "MicrosoftSQLServer",
"sku": "sqldev",
"version": "latest"
},
"mssql2019dev-ubuntu1804": {
"offer": "sql2019-ubuntu1804",
"publisher": "MicrosoftSQLServer",
"sku": "sqldev",
"version": "latest"
},
"mssql2019dev-ubuntu2004": {
"offer": "sql2019-ubuntu2004",
"publisher": "MicrosoftSQLServer",
"sku": "sqldev",
"version": "latest"
},
"mssql2019ent-rhel8": {
"offer": "sql2019-rhel8",
"publisher": "MicrosoftSQLServer",
"sku": "enterprise",
"version": "latest"
},
"mssql2019ent-ubuntu1804": {
"offer": "sql2019-ubuntu1804",
"publisher": "MicrosoftSQLServer",
"sku": "enterprise",
"version": "latest"
},
"mssql2019ent-ubuntu2004": {
"offer": "sql2019-ubuntu2004",
"publisher": "MicrosoftSQLServer",
"sku": "enterprise",
"version": "latest"
},
"mssql2019std-rhel8": {
"offer": "sql2019-rhel8",
"publisher": "MicrosoftSQLServer",
"sku": "standard",
"version": "latest"
},
"mssql2019std-ubuntu1804": {
"offer": "sql2019-ubuntu1804",
"publisher": "MicrosoftSQLServer",
"sku": "standard",
"version": "latest"
},
"mssql2019std-ubuntu2004": {
"offer": "sql2019-ubuntu2004",
"publisher": "MicrosoftSQLServer",
"sku": "standard",
"version": "latest"
},
"rhel78": {
"offer": "RHEL",
"publisher": "RedHat",
"sku": "7.8",
"version": "latest"
},
"rhel78-gen2": {
"offer": "RHEL",
"publisher": "RedHat",
"sku": "78-gen2",
"version": "latest"
},
"rhel79": {
"offer": "RHEL",
"publisher": "RedHat",
"sku": "7.9",
"version": "latest"
},
"rhel79-gen2": {
"offer": "RHEL",
"publisher": "RedHat",
"sku": "79-gen2",
"version": "latest"
},
"rhel81": {
"offer": "RHEL",
"publisher": "RedHat",
"sku": "8.1",
"version": "latest"
},
"rhel81-gen2": {
"offer": "RHEL",
"publisher": "RedHat",
"sku": "81gen2",
"version": "latest"
},
"rhel82": {
"offer": "RHEL",
"publisher": "RedHat",
"sku": "8.2",
"version": "latest"
},
"rhel82-gen2": {
"offer": "RHEL",
"publisher": "RedHat",
"sku": "82gen2",
"version": "latest"
},
"rhel83": {
"offer": "RHEL",
"publisher": "RedHat",
"sku": "8.3",
"version": "latest"
},
"rhel83-gen2": {
"offer": "RHEL",
"publisher": "RedHat",
"sku": "83gen2",
"version": "latest"
},
"rhel84": {
"offer": "RHEL",
"publisher": "RedHat",
"sku": "8.4",
"version": "latest"
},
"rhel84-byos": {
"offer": "rhel-byos",
"publisher": "RedHat",
"sku": "rhel-lvm84",
"version": "latest"
},
"rhel84-byos-gen2": {
"offer": "rhel-byos",
"publisher": "RedHat",
"sku": "rhel-lvm84-gen2",
"version": "latest"
},
"rhel84-gen2": {
"offer": "RHEL",
"publisher": "RedHat",
"sku": "84gen2",
"version": "latest"
},
"ubuntu1604": {
"offer": "UbuntuServer",
"publisher": "Canonical",
"sku": "16.04-LTS",
"version": "latest"
},
"ubuntu1804": {
"offer": "UbuntuServer",
"publisher": "Canonical",
"sku": "18.04-LTS",
"version": "latest"
},
"ubuntu1904": {
"offer": "UbuntuServer",
"publisher": "Canonical",
"sku": "19.04",
"version": "latest"
},
"ubuntu2004": {
"offer": "0001-com-ubuntu-server-focal-daily",
"publisher": "Canonical",
"sku": "20_04-daily-lts",
"version": "latest"
},
"ubuntu2004-gen2": {
"offer": "0001-com-ubuntu-server-focal-daily",
"publisher": "Canonical",
"sku": "20_04-daily-lts-gen2",
"version": "latest"
}
}
no
linux_distribution_name Variable to pick an OS flavor for Linux based VM. Possible values include: centos8, ubuntu1804 string "ubuntu1804" no
load_balancer_backend_pool_id Id of the Load Balancer Backend Pool to attach the VM. string null no
location Azure region in which instance will be hosted string n/a yes
log_analytics_customer_id The Workspace (or Customer) ID for the Log Analytics Workspace. any null no
log_analytics_workspace_id The name of log analytics workspace resource id any null no
log_analytics_workspace_primary_shared_key The Primary shared key for the Log Analytics Workspace any null no
managed_identity_ids A list of User Managed Identity ID's which should be assigned to the Linux Virtual Machine. any null no
managed_identity_type The type of Managed Identity which should be assigned to the Linux Virtual Machine. Possible values are SystemAssigned, UserAssigned and SystemAssigned, UserAssigned any null no
name_prefix Optional prefix for the generated name string "" no
name_suffix Optional suffix for the generated name string "" no
nic_add_tags Extra tags to set on the network interface. map(string) {} no
nsg_diag_logs NSG Monitoring Category details for Azure Diagnostic setting list
[
"NetworkSecurityGroupEvent",
"NetworkSecurityGroupRuleCounter"
]
no
nsg_inbound_rules List of network rules to apply to network interface. list [] no
org_name Name of the organization string n/a yes
os_disk_add_tags Extra tags to set on the OS disk. map(string) {} no
os_disk_caching The Type of Caching which should be used for the Internal OS Disk. Possible values are None, ReadOnly and ReadWrite string "ReadWrite" no
os_disk_custom_name Custom name for OS disk. Generated if not set. string null no
os_disk_name The name which should be used for the Internal OS Disk any null no
os_disk_overwrite_tags True to overwrite existing OS disk tags instead of merging. bool false no
os_disk_storage_account_type The Type of Storage Account which should back this the Internal OS Disk. Possible values include Standard_LRS, StandardSSD_LRS and Premium_LRS. string "StandardSSD_LRS" no
os_disk_tagging_enabled Should OS disk tagging be enabled? Defaults to true. bool true no
os_type Specify the type of the operating system image to deploy Virtual Machine. Valid values are windows and linux Default vaule is windows string "windows" no
patch_mode Specifies the mode of in-guest patching to Linux or Windows Virtual Machine. Possible values are Manual, AutomaticByOS and AutomaticByPlatform string "AutomaticByOS" no
platform_fault_domain_count Specifies the number of fault domains that are used number 3 no
platform_update_domain_count Specifies the number of update domains that are used number 5 no
private_ip_address The Static IP Address which should be used. This is valid only when private_ip_address_allocation is set to Static any null no
private_ip_address_allocation_type The allocation method used for the Private IP Address. Possible values are Dynamic and Static. string "Dynamic" no
public_ip_add_tags Extra tags to set on the public IP resource. map(string) {} no
public_ip_allocation_method Defines the allocation method for this IP address. Possible values are Static or Dynamic string "Static" no
public_ip_availability_zone The availability zone to allocate the Public IP in. Possible values are 1,2,3 list
[
"1",
"2",
"3"
]
no
public_ip_sku The SKU of the Public IP. Accepted values are Basic and Standard string "Standard" no
public_ip_sku_tier The SKU Tier that should be used for the Public IP. Possible values are Regional and Global string "Regional" no
random_password_length The desired length of random password created by this module number 24 no
source_image_id The ID of an Image which each Virtual Machine should be based on any null no
storage_account_name The name of the hub storage account to store logs any null no
storage_account_uri The Primary/Secondary Endpoint for the Azure Storage Account which should be used to store Boot Diagnostics, including Console Output and Screenshots from the Hypervisor. Passing a null value will utilize a Managed Storage Account to store Boot Diagnostics. any null no
subnet_name The name of the subnet to use in VM scale set any null no
use_location_short_name Use short location name for resources naming (ie eastus -> eus). Default is true. If set to false, the full cli location name will be used. if custom naming is set, this variable will be ignored. bool true no
use_naming Use the Azure NoOps naming provider to generate default resource name. storage_account_custom_name override this if set. Legacy default name is used if this is set to false. bool true no
virtual_machine_size The Virtual Machine SKU for the Virtual Machine, Default is Standard_A2_V2 string "Standard_A2_v2" no
virtual_network_name The name of the virtual network any null no
vm_availability_zone The Zone in which this Virtual Machine should be created. Conflicts with availability set and shouldn't use both any null no
vm_time_zone Specifies the Time Zone which should be used by the Virtual Machine any null no
windows_distribution_list Pre-defined Azure Windows VM images list
map(object({
publisher = string
offer = string
sku = string
version = string
}))
{
"mssql2017dev": {
"offer": "SQL2017-WS2019",
"publisher": "MicrosoftSQLServer",
"sku": "sqldev",
"version": "latest"
},
"mssql2017ent": {
"offer": "SQL2017-WS2019",
"publisher": "MicrosoftSQLServer",
"sku": "enterprise",
"version": "latest"
},
"mssql2017exp": {
"offer": "SQL2017-WS2019",
"publisher": "MicrosoftSQLServer",
"sku": "express",
"version": "latest"
},
"mssql2017std": {
"offer": "SQL2017-WS2019",
"publisher": "MicrosoftSQLServer",
"sku": "standard",
"version": "latest"
},
"mssql2019dev": {
"offer": "sql2019-ws2019",
"publisher": "MicrosoftSQLServer",
"sku": "sqldev",
"version": "latest"
},
"mssql2019ent": {
"offer": "sql2019-ws2019",
"publisher": "MicrosoftSQLServer",
"sku": "enterprise",
"version": "latest"
},
"mssql2019ent-byol": {
"offer": "sql2019-ws2019-byol",
"publisher": "MicrosoftSQLServer",
"sku": "enterprise",
"version": "latest"
},
"mssql2019std": {
"offer": "sql2019-ws2019",
"publisher": "MicrosoftSQLServer",
"sku": "standard",
"version": "latest"
},
"mssql2019std-byol": {
"offer": "sql2019-ws2019-byol",
"publisher": "MicrosoftSQLServer",
"sku": "standard",
"version": "latest"
},
"windows2012r2dc": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2012-R2-Datacenter",
"version": "latest"
},
"windows2016dc": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter",
"version": "latest"
},
"windows2016dccore": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2016-Datacenter-Server-Core",
"version": "latest"
},
"windows2019dc": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2019-Datacenter",
"version": "latest"
},
"windows2019dc-containers": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2019-Datacenter-with-Containers",
"version": "latest"
},
"windows2019dc-containers-g2": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2019-datacenter-with-containers-g2",
"version": "latest"
},
"windows2019dc-gensecond": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2019-datacenter-gensecond",
"version": "latest"
},
"windows2019dc-gs": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2019-datacenter-gs",
"version": "latest"
},
"windows2019dccore": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2019-Datacenter-Core",
"version": "latest"
},
"windows2019dccore-g2": {
"offer": "WindowsServer",
"publisher": "MicrosoftWindowsServer",
"sku": "2019-datacenter-core-g2",
"version": "latest"
}
}
no
windows_distribution_name Variable to pick an OS flavor for Windows based VM. Possible values include: winserver, wincore, winsql string "windows2019dc" no
winrm_protocol Specifies the protocol of winrm listener. Possible values are Http or Https any null no
workload_name Name of the workload_name string n/a yes

Outputs

Name Description
admin_ssh_key_private The generated private key data in PEM format
admin_ssh_key_public The generated public key data in PEM format
linux_virtual_machine_ids The resource id's of all Linux Virtual Machine.
linux_vm_password Password for the Linux VM
linux_vm_private_ips Public IP's map for the all windows Virtual Machines
linux_vm_public_ips Public IP's map for the all windows Virtual Machines
network_security_group_ids List of Network security groups and ids
vm_availability_set_id The resource ID of Virtual Machine availability set
windows_virtual_machine_ids The resource id's of all Windows Virtual Machine.
windows_vm_password Password for the windows VM
windows_vm_private_ips Public IP's map for the all windows Virtual Machines
windows_vm_public_ips Public IP's map for the all windows Virtual Machines

Other resources