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:
juan-acevedo-ntt 2020-12-02 08:29:11 +01:00 коммит произвёл GitHub
Родитель 3032f5e061
Коммит c6987b39af
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 53 добавлений и 0 удалений

Просмотреть файл

@ -227,6 +227,18 @@ module "windowsservers" {
enable_accelerated_networking = true enable_accelerated_networking = true
license_type = "Windows_Client" license_type = "Windows_Client"
identity_type = "SystemAssigned" // can be empty, SystemAssigned or UserAssigned identity_type = "SystemAssigned" // can be empty, SystemAssigned or UserAssigned
extra_disks = [
{
size = 50
name = "logs"
},
{
size = 200
name = "backup"
}
]
os_profile_secrets = [{ os_profile_secrets = [{
source_vault_id = data.azurerm_key_vault.example.id source_vault_id = data.azurerm_key_vault.example.id
certificate_url = data.azurerm_key_vault_certificate.example.secret_id certificate_url = data.azurerm_key_vault_certificate.example.secret_id

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 { os_profile {
computer_name = "${var.vm_hostname}-${count.index}" computer_name = "${var.vm_hostname}-${count.index}"
admin_username = var.admin_username 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 { os_profile {
computer_name = "${var.vm_hostname}-${count.index}" computer_name = "${var.vm_hostname}-${count.index}"
admin_username = var.admin_username admin_username = var.admin_username

Просмотреть файл

@ -86,6 +86,16 @@ module "debianservers" {
allocation_method = "Static" allocation_method = "Static"
enable_ssh_key = true enable_ssh_key = true
extra_ssh_keys = ["monica_id_rsa.pub"] extra_ssh_keys = ["monica_id_rsa.pub"]
extra_disks = [
{
size = 5
name = "extra1"
},
{
size = 5
name = "extra2"
}
]
depends_on = [azurerm_resource_group.test] depends_on = [azurerm_resource_group.test]
} }

Просмотреть файл

@ -221,6 +221,15 @@ variable "identity_ids" {
default = [] 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" { 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." 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)) type = list(map(string))