-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
33 lines (29 loc) · 1.19 KB
/
main.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
resource "azurerm_disk_encryption_set" "this" {
location = var.location
name = var.name
resource_group_name = var.resource_group_name
auto_key_rotation_enabled = var.auto_key_rotation_enabled
encryption_type = var.encryption_type
federated_client_id = var.federated_client_id
key_vault_key_id = var.key_vault_key_id
managed_hsm_key_id = var.managed_hsm_key_id
dynamic "identity" {
for_each = coalesce(local.identity_system_assigned_user_assigned, local.identity_system_assigned, local.identity_user_assigned)
content {
type = identity.value.type
identity_ids = identity.value.user_assigned_resource_ids
}
}
tags = merge(
try(var.tags),
tomap({
"Resource Type" = "Disk Encryption Set"
})
)
}
resource "azurerm_role_assignment" "this" {
count = (local.identity_system_assigned != null || local.identity_system_assigned_user_assigned != null) ? 1 : 0
principal_id = azurerm_disk_encryption_set.this.identity[0].principal_id
scope = var.key_vault_resource_id
role_definition_name = "Key Vault Crypto Service Encryption User"
}