Adding support for the 'extra_disks' parameter (#152)
* Adding support for the 'extra_disks' parameter * Adding a new parameter 'extra_disks' to add custom size data disks * updated README.md * updated main.tf * updated variables.tf * tested on TF v0.13.5 * Test added for extra_disks and format fixed * Update README.md * Fix typo in variables.tf * Update variables.tf Co-authored-by: Yuping Wei <56525716+yupwei68@users.noreply.github.com>
This commit is contained in:
Родитель
3032f5e061
Коммит
c6987b39af
12
README.md
12
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
|
||||
|
|
22
main.tf
22
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
|
||||
|
|
|
@ -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]
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
|
|
Загрузка…
Ссылка в новой задаче