forked from hmcts/terraform-module-virtual-machine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
015-disks.tf
46 lines (39 loc) · 1.84 KB
/
015-disks.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
resource "azurerm_managed_disk" "managed_disks" {
for_each = var.managed_disks
name = each.value.name
location = each.value.location
resource_group_name = each.value.resource_group_name
storage_account_type = each.value.storage_account_type
# Valid options are Import, Empty, Copy, FromImage, Restore
create_option = each.value.disk_create_option
disk_size_gb = each.value.disk_size_gb
tier = each.value.disk_tier
zone = each.value.disk_zone
source_resource_id = each.value.source_resource_id
storage_account_id = each.value.storage_account_id
hyper_v_generation = each.value.hyper_v_generation
os_type = each.value.os_type
disk_encryption_set_id = var.encrypt_CMK ? azurerm_disk_encryption_set.disk_enc_set[0].id : null
tags = var.tags
depends_on = [
azurerm_linux_virtual_machine.linvm,
azurerm_windows_virtual_machine.winvm
]
lifecycle {
#ignore disk encryption changes because its get encrypted by the extension
ignore_changes = [encryption_settings]
}
}
resource "azurerm_virtual_machine_data_disk_attachment" "data_disk_attachments" {
for_each = var.managed_disks
managed_disk_id = azurerm_managed_disk.managed_disks[each.key].id
virtual_machine_id = var.vm_type == "linux" ? azurerm_linux_virtual_machine.linvm[0].id : azurerm_windows_virtual_machine.winvm[0].id
lun = each.value.disk_lun
caching = each.value.disk_caching
# Valid options are Attach Empty. See https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_machine_data_disk_attachment#create_option
create_option = each.value.attachment_create_option
depends_on = [
azurerm_linux_virtual_machine.linvm,
azurerm_windows_virtual_machine.winvm
]
}