Skip to content

Commit da63520

Browse files
committed
Rename and refactoring az-disk-encryption-set to az-des
1 parent 80c1338 commit da63520

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

terraform/modules/az-des/main.tf

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
locals {
2-
identity_ids_with_index = { for idx, id in var.identity_ids : idx => id }
3-
}
4-
5-
61
resource "azurerm_key_vault_key" "des" {
72
name = var.name
83
key_vault_id = var.kv_id
@@ -30,24 +25,26 @@ resource "azurerm_key_vault_key" "des" {
3025
expiration_date = var.expiration_date
3126
}
3227

28+
resource "azurerm_role_assignment" "des" {
29+
scope = var.kv_id
30+
role_definition_name = "Key Vault Crypto Service Encryption User"
31+
principal_id = var.principal_id
32+
}
33+
3334
resource "azurerm_disk_encryption_set" "des" {
35+
36+
depends_on = [azurerm_role_assignment.des]
37+
3438
name = var.name
3539
resource_group_name = var.resource_group_name
3640
location = var.location
3741
key_vault_key_id = azurerm_key_vault_key.des.id
3842

3943
identity {
4044
type = "UserAssigned"
41-
identity_ids = var.identity_ids
45+
identity_ids = [var.identity_id]
4246
}
4347

4448
tags = var.tags
4549
}
4650

47-
resource "azurerm_role_assignment" "des" {
48-
for_each = local.identity_ids_with_index
49-
50-
scope = var.kv_id
51-
role_definition_name = "Key Vault Crypto Service Encryption User"
52-
principal_id = each.value
53-
}

terraform/modules/az-des/variables.tf

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,14 @@ variable "expiration_date" {
4848
default = null
4949
}
5050

51-
variable "identity_ids" {
52-
description = "A list of User Assigned Identity IDs to assign to the Disk Encryption Set."
53-
type = list(string)
51+
variable "identity_id" {
52+
description = "The ID of the identity to assign to the disk encryption set."
53+
type = string
54+
}
55+
56+
variable "principal_id" {
57+
description = "The ID of the principal to assign to the disk encryption set."
58+
type = string
5459
}
5560

5661
variable "tags" {

0 commit comments

Comments
 (0)