File tree Expand file tree Collapse file tree 2 files changed +18
-16
lines changed Expand file tree Collapse file tree 2 files changed +18
-16
lines changed Original file line number Diff line number Diff line change 1
- locals {
2
- identity_ids_with_index = { for idx , id in var . identity_ids : idx => id }
3
- }
4
-
5
-
6
1
resource "azurerm_key_vault_key" "des" {
7
2
name = var. name
8
3
key_vault_id = var. kv_id
@@ -30,24 +25,26 @@ resource "azurerm_key_vault_key" "des" {
30
25
expiration_date = var. expiration_date
31
26
}
32
27
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
+
33
34
resource "azurerm_disk_encryption_set" "des" {
35
+
36
+ depends_on = [azurerm_role_assignment . des ]
37
+
34
38
name = var. name
35
39
resource_group_name = var. resource_group_name
36
40
location = var. location
37
41
key_vault_key_id = azurerm_key_vault_key. des . id
38
42
39
43
identity {
40
44
type = " UserAssigned"
41
- identity_ids = var. identity_ids
45
+ identity_ids = [ var . identity_id ]
42
46
}
43
47
44
48
tags = var. tags
45
49
}
46
50
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
- }
Original file line number Diff line number Diff line change @@ -48,9 +48,14 @@ variable "expiration_date" {
48
48
default = null
49
49
}
50
50
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
54
59
}
55
60
56
61
variable "tags" {
You can’t perform that action at this time.
0 commit comments