diff --git a/README.md b/README.md index 41640c0..9d25e0f 100644 --- a/README.md +++ b/README.md @@ -227,6 +227,18 @@ module "windowsservers" { enable_accelerated_networking = true license_type = "Windows_Client" identity_type = "SystemAssigned" // can be empty, SystemAssigned or UserAssigned + + extra_disks = [ + { + size = 50 + name = "logs" + }, + { + size = 200 + name = "backup" + } + ] + os_profile_secrets = [{ source_vault_id = data.azurerm_key_vault.example.id certificate_url = data.azurerm_key_vault_certificate.example.secret_id diff --git a/main.tf b/main.tf index 3bdd186..4dfec7b 100644 --- a/main.tf +++ b/main.tf @@ -80,6 +80,17 @@ resource "azurerm_virtual_machine" "vm-linux" { } } + dynamic storage_data_disk { + for_each = var.extra_disks + content { + name = "${var.vm_hostname}-extradisk-${count.index}-${storage_data_disk.value.name}" + create_option = "Empty" + lun = storage_data_disk.key + var.nb_data_disk + disk_size_gb = storage_data_disk.value.size + managed_disk_type = var.data_sa_type + } + } + os_profile { computer_name = "${var.vm_hostname}-${count.index}" admin_username = var.admin_username @@ -170,6 +181,17 @@ resource "azurerm_virtual_machine" "vm-windows" { } } + dynamic storage_data_disk { + for_each = var.extra_disks + content { + name = "${var.vm_hostname}-extradisk-${count.index}-${storage_data_disk.value.name}" + create_option = "Empty" + lun = storage_data_disk.key + var.nb_data_disk + disk_size_gb = storage_data_disk.value.size + managed_disk_type = var.data_sa_type + } + } + os_profile { computer_name = "${var.vm_hostname}-${count.index}" admin_username = var.admin_username diff --git a/test/fixture/main.tf b/test/fixture/main.tf index 6c490e1..f534a58 100644 --- a/test/fixture/main.tf +++ b/test/fixture/main.tf @@ -86,6 +86,16 @@ module "debianservers" { allocation_method = "Static" enable_ssh_key = true extra_ssh_keys = ["monica_id_rsa.pub"] + extra_disks = [ + { + size = 5 + name = "extra1" + }, + { + size = 5 + name = "extra2" + } + ] depends_on = [azurerm_resource_group.test] } diff --git a/variables.tf b/variables.tf index e392364..f58752e 100644 --- a/variables.tf +++ b/variables.tf @@ -221,6 +221,15 @@ variable "identity_ids" { default = [] } +variable "extra_disks" { + description = "(Optional) List of extra data disks attached to each virtual machine." + type = list(object({ + name = string + size = number + })) + default = [] +} + variable "os_profile_secrets" { description = "Specifies a list of certificates to be installed on the VM, each list item is a map with the keys source_vault_id, certificate_url and certificate_store." type = list(map(string))