Terraform module to create Virtual Machines in Azure.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Guillaume Donval 80cc66d921
fix: fixes outputs
6 days ago
examples fix: removes problematic outputs 6 days ago
.gitignore tech: adds .gitignore file 4 weeks ago
.pre-commit-config.yaml fix: brings back provider to earlier version 3 weeks ago
CHANGELOG.md doc: updates CHANGELOG 6 days ago
Jenkinsfile test: adds base Jenkinsfile 4 weeks ago
LICENSE tech: adds LICENSE file 4 weeks ago
README.md fix: fixes outputs 6 days ago
data.tf refactor: renames network_interface_names to network_interface_external_names in preparation of multiple network interfaces 2 weeks ago
main.tf fix: reintroduces count because terraform 6 days ago
outputs.tf fix: fixes outputs 6 days ago
variables.tf fix: reintroduces count because terraform 6 days ago
versions.tf refactor: bimps minimal version needed 2 weeks ago

README.md

terraform-module-azurerm-virtual-machine

Usage

See examples folders for usage of this module.

Limitation

  • Any call of this module will create resources in a single resource group.
  • Any network interfaces created in this module will have a single ip_configuration.
  • Tags for VMs are shared among all VMs. Same thing for managed disks.
  • Managed disks cannot be encrypted.

Providers

Name Version
azurerm n/a

Inputs

Name Description Type Default Required
additional_capabilities_ultra_ssd_enabled Should Ultra SSD disk be enabled for this Virtual Machine? bool false no
additional_unattend_config_content Specifies the base-64 encoded XML formatted content that is added to the unattend.xml file for the specified path and component. string "" no
additional_unattend_config_setting_name Specifies the name of the setting to which the content applies. Possible values are: FirstLogonCommands and AutoLogon. string "FirstLogonCommands" no
availability_set_enabled Whether or not to create an availability set. bool true no
availability_set_exists If defined, the existing availability set will be used by virtual machines instead of creating a new availability set inside this module. bool false no
availability_set_managed Specifies whether the availability set is managed or not. Possible values are true (to specify aligned) or false (to specify classic). bool true no
availability_set_name Specifies the name of the availability set. Changing this forces a new resource to be created. string "" no
availability_set_tags Tags specific to the availability set. map {} no
boot_diagnostics_enabled Should Boot Diagnostics be enabled for this Virtual Machine? bool false no
boot_diagnostics_storage_uri The Storage Account’s Blob Endpoint which should hold the virtual machine’s diagnostic files. string "" no
delete_data_disks_on_termination Should the Data Disks (either the Managed Disks / VHD Blobs) be deleted when the Virtual Machine is destroyed? bool false no
delete_os_disk_on_termination Should the OS Disk (either the Managed Disk / VHD Blob) be deleted when the Virtual Machine is destroyed? bool false no
enabled Enable or disable module bool true no
license_type Specifies the BYOL Type for this Virtual Machine. This is only applicable to Windows Virtual Machines. Possible values are Windows_Client and Windows_Server. string "Windows_Server" no
managed_disk_cachings Specifies the caching requirements for the Managed Disks. Possible values include None, ReadOnly and ReadWrite. list(string)
[
“ReadWrite”
]
no
managed_disk_count How many additional managed disk to attach to EACH Virtual Machines. number 0 no
managed_disk_create_options The methods to use when creating the Managed Disks. Possible values include: Empty, FromImage, Copy, Import, Restore. list(string)
[
“Empty”
]
no
managed_disk_image_reference_ids IDs of an existing platform/marketplace disk image to copy when create_option is FromImage. CAREFUL: if you create multiple Managed Disks with different create_option, make sure this list matches with the disks having “FromImage” on (meaning this list may have empty values). list(string)
[
“”
]
no
managed_disk_names Specifies the names of the Managed Disks. Changing this forces a new resource to be created. list(string)
[
“vm-manage-disk”
]
no
managed_disk_os_types Specify values when the source of an Import or Copy operation targets a source that contains an operating system. Valid values inside the list are Linux or Windows. CAREFUL: if you create multiple Managed Disks with different create_option, make sure this list matches with the disks having “Copy”/“Import” on (meaning this list may have empty values). list(string)
[
“Linux”
]
no
managed_disk_size_gbs Specifies the sizes of the Managed Disks to create in gigabytes. If create_option is Copy or FromImage, then the value must be equal to or greater than the source’s size. list(number)
[
5
]
no
managed_disk_source_resource_ids The IDs of existing Managed Disks to copy create_option is Copy or the recovery points to restore when create_option is Restore. CAREFUL: if you create multiple Managed Disks with different create_option, make sure this list matches with the disks having “Copy”/“Restore” on (meaning this list may have empty values). list(string)
[
“”
]
no
managed_disk_source_uris URI to a valid VHD file to be used when create_option is Import. CAREFUL: if you create multiple Managed Disks with different create_option, make sure this list matches with the disks having “Import” on (meaning this list may have empty values). list(string)
[
“”
]
no
managed_disk_storage_account_types The types of storage to use for the Managed Disks. Possible values inside the list are Standard_LRS, Premium_LRS, StandardSSD_LRS or UltraSSD_LRS. list(string)
[
“Standard_LRS”
]
no
managed_disk_tags Tags specific to the Managed Disks. map {} no
managed_disk_write_accelerator_enableds Specifies if Write Accelerator is enabled on Managed Disks. This can only be enabled on Premium_LRS managed disks with no caching and M-Series VMs. list(bool)
[
false
]
no
name Specifies the name of the Virtual Machine. Changing this forces a new resource to be created. string "vm" no
network_interface_application_gateway_backend_address_pool_count How many Gateway Backend Address Pools to associate per Network Interface. number 0 no
network_interface_application_gateway_backend_address_pool_ids The IDs of the Application Gateway’s Backend Address Pools which each Network Interfaces which should be connected to. Changing this forces a new resource to be created. Beware: network_interface_index value is the index per Virtual Machine. list(object({ network_interface_index = number, application_gateway_backend_address_pool_id = string }))
[
{
“application_gateway_backend_address_pool_id”: “”,
“network_interface_index”: 0
}
]
no
network_interface_application_security_group_count How many Network Interfaces security groups to associate per Network Interface. number 0 no
network_interface_application_security_group_ids The IDs of the Application Security Groups which each Network Interfaces which should be connected to. Changing this forces a new resource to be created. Beware: network_interface_index value is the index per Virtual Machine. list(object({ network_interface_index = number, application_security_group_id = string }))
[
{
“application_security_group_id”: “”,
“network_interface_index”: 0
}
]
no
network_interface_backend_address_pool_count How many Backend Address Pools to associate per Network Interface. number 0 no
network_interface_backend_address_pool_ids The IDs of the Load Balancer Backend Address Pools which each Network Interfaces which should be connected to. Changing this forces a new resource to be created. Beware: network_interface_index value is the index per Virtual Machine. list(object({ network_interface_index = number, backend_address_pool_id = string }))
[
{
“backend_address_pool_id”: “”,
“network_interface_index”: 0
}
]
no
network_interface_count How many Network Interfaces to create per Virtual Machine. number 1 no
network_interface_dns_servers List of DNS servers IP addresses to use for this NIC, overrides the VNet-level server list list(list(string))
[
null
]
no
network_interface_enable_accelerated_networkings Enables Azure Accelerated Networking using SR-IOV. Only certain VM instance sizes are supported. list(bool)
[
false
]
no
network_interface_enable_ip_forwardings Enables IP Forwarding on the NICs. list(bool)
[
false
]
no
network_interface_enabled Whether or not to create a network interface. bool true no
network_interface_exists If defined, will use var.network_interface_external_names to get network interfaces instead of creating a new network interfaces inside this module. bool false no
network_interface_external_names If defined, this network interfaces will be used by other virtual machines instead of creating a new network interfaces inside this module. list
[
“”
]
no
network_interface_internal_dns_name_labels Relative DNS names for this NIC used for internal communications between VMs in the same VNet. list(string)
[
“”
]
no
network_interface_ip_configuration_names User-defined name of the IPs for the Network Interfaces. Careful: this defines all the IP configurations meaning network_interface_count times vm_count. list(string)
[
“”
]
no
network_interface_ip_configuration_private_ip_address_allocations Defines how a private IP addresses are assigned. Options are Static or Dynamic. Careful: this defines all the IP configurations meaning network_interface_count times vm_count. list(string)
[
“Dynamic”
]
no
network_interface_ip_configuration_private_ip_address_versions The IP versions to use. Possible values are IPv4 or IPv6. Careful: this defines all the IP configurations meaning network_interface_count times vm_count. list(string)
[
“IPv4”
]
no
network_interface_ip_configuration_private_ip_addresses Static IP Addresses. Careful: this defines all the IP configurations meaning network_interface_count times vm_count. list(string)
[
“”
]
no
network_interface_ip_configuration_public_ip_address_ids Reference to a Public IP Address to associate with this NIC. Careful: this defines all the IP configurations meaning network_interface_count times vm_count. list(string)
[
“”
]
no
network_interface_ip_configuration_subnet_ids Reference to subnets in which this NICs have been created. Required when private_ip_address_versions is IPv4. Careful: this defines all the IP configurations meaning network_interface_count times vm_count. list(string)
[
“”
]
no
network_interface_names The name of the network interface. Changing this forces a new resource to be created. list
[
“net-interface”
]
no
network_interface_nat_rule_association_count How many NAT Rules to associate per Network Interface. number 0 no
network_interface_nat_rule_association_ids The IDs of the Load Balancer NAT Rules which each Network Interfaces which should be connected to. Changing this forces a new resource to be created. Beware: network_interface_index value is the index per Virtual Machine. list(object({ network_interface_index = number, nat_rule_id = string }))
[
{
“nat_rule_id”: “”,
“network_interface_index”: 0
}
]
no
network_interface_network_security_group_ids The IDs of the Network Security Groups to associate with the network interfaces. list
[
“”
]
no
network_interface_tags Tags specific to the network interface. map {} no
num_suffix_digits How many digits to use for resources names. number 2 no
os_profile_admin_password The password associated with the local administrator account. string "Passw0rd_TO_BE_CHANGED!" no
os_profile_admin_username Specifies the name of the local administrator account. string "testadmin" no
os_profile_custom_data Specifies custom data to supply to the machine. On Linux-based systems, this can be used as a cloud-init script. On other systems, this will be copied as a file on disk. Internally, Terraform will base64 encode this value before sending it to the API. The maximum length of the binary array is 65535 bytes. string "" no
os_profile_linux_config_disable_password_authentication Specifies whether password authentication should be disabled. If set to false, an admin_password must be specified. bool true no
os_profile_linux_config_ssh_keys One or more ssh_keys blocks. This field is required if disable_password_authentication is set to true. list(object({ key_data = string })) [] no
os_profile_secrets_source_vault_id Specifies the ID of the Key Vault to use. string "" no
os_profile_secrets_vault_certificates One or more vault_certificates blocks. list(object({ certificate_url = string, certificate_store = string })) [] no
os_profile_windows_config_enable_automatic_upgrades Are automatic updates enabled on this Virtual Machine? bool false no
os_profile_windows_config_provision_vm_agent Should the Azure Virtual Machine Guest Agent be installed on this Virtual Machine? bool false no
os_profile_windows_config_timezone Specifies the time zone of the virtual machine string "UTC" no
plan_name Specifies the name of the image from the marketplace. string "" no
plan_product Specifies the product of the image from the marketplace. string "" no
plan_publisher Specifies the publisher of the image. string "" no
resource_group_location pecifies the supported Azure location where the resources exist. Changing this forces a new resource to be created. string "" no
resource_group_name The name of the resource group in which to create the resources in this module. Changing this forces a new resource to be created. string "" no
storage_image_reference_id Specifies the ID of the Custom Image which the Virtual Machine should be created from. Changing this forces a new resource to be created. string "" no
storage_image_reference_offer Specifies the offer of the image used to create the virtual machine. Changing this forces a new resource to be created. string "UbuntuServer" no
storage_image_reference_publisher Specifies the publisher of the image used to create the virtual machine. Changing this forces a new resource to be created. string "Canonical" no
storage_image_reference_sku Specifies the SKU of the image used to create the virtual machine. Changing this forces a new resource to be created. string "18.04-LTS" no
storage_image_reference_version Specifies the version of the image used to create the virtual machine. Changing this forces a new resource to be created. string "latest" no
storage_os_disk_caching Specifies the caching requirements for the OS Disk. Possible values include None, ReadOnly and ReadWrite. string "ReadWrite" no
storage_os_disk_create_option Specifies how the OS Disk should be created. Possible values are Attach (managed disks only) and FromImage. string "FromImage" no
storage_os_disk_name Specifies how the OS Disk should be created. Possible values are Attach (managed disks only) and FromImage. string "vm-disk" no
storage_os_disk_size_gb Specifies the size of the OS Disk in gigabytes. number 30 no
storage_os_managed_disk_id SSpecifies the ID of an existing Managed Disk which should be attached as the OS Disk of this Virtual Machine. If this is set then the create_option must be set to Attach. string "" no
storage_os_managed_disk_type Specifies the type of Managed Disk which should be created. Possible values are Standard_LRS, StandardSSD_LRS or Premium_LRS. string "Standard_LRS" no
storage_os_vhd_uri Specifies the URI of the VHD file backing this Unmanaged OS Disk. Changing this forces a new resource to be created. string "" no
storage_os_write_accelerator_enabled Specifies if Write Accelerator is enabled on the disk. This can only be enabled on Premium_LRS managed disks with no caching and M-Series VMs. bool false no
tags Tags shared by all resources of this module. Will be merged with any other specific tags by resource map {} no
vm_count How many Virtual Machines to create. number 1 no
vm_size Specifies the size of the Virtual Machines. https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sizes?toc=%2Fazure%2Fvirtual-machines%2Fwindows%2Ftoc.json. string "Standard_B1ls" no
vm_tags Tags specific to the Virtual Machines. map {} no
vm_type The type of Virtual Machines to create. Can be either “Linux” or “Windows”. string "Linux" no
winrm_certificate_url The ID of the Key Vault Secret which contains the encrypted Certificate which should be installed on the Virtual Machine. This certificate must also be specified in the vault_certificates block within the os_profile_secrets block. string "" no
winrm_protocol Specifies the protocol of listener. Possible values are HTTP or HTTPS. string "HTTPS" no

Outputs

Name Description
availability_set_id n/a
azurerm_managed_disk_ids n/a
identities n/a
ids n/a
network_interface_ids n/a
network_interface_mac_addresses n/a
network_interface_private_ip_addresses n/a