forked from Azure/terraform-azurerm-caf-enterprise-scale
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathresources.role_assignments.tf
70 lines (56 loc) · 2.54 KB
/
resources.role_assignments.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
resource "azurerm_role_assignment" "enterprise_scale" {
for_each = local.azurerm_role_assignment_enterprise_scale
# Special handling of OPTIONAL name to ensure consistent and correct
# mapping of Terraform state ADDR value to Azure Resource ID value.
name = basename(each.key)
# Mandatory resource attributes
scope = each.value.scope_id
principal_id = each.value.principal_id
# Optional attributes
role_definition_name = try(each.value.role_definition_name, null)
role_definition_id = try(each.value.role_definition_id, null)
# Set explicit dependency on Management Group, Policy, and Role Definition deployments
depends_on = [
time_sleep.after_azurerm_management_group,
time_sleep.after_azurerm_policy_definition,
time_sleep.after_azurerm_policy_set_definition,
time_sleep.after_azurerm_policy_assignment,
time_sleep.after_azurerm_role_definition,
]
}
resource "azurerm_role_assignment" "policy_assignment" {
for_each = local.azurerm_role_assignment_policy_assignment
# Special handling of OPTIONAL name to ensure consistent and correct
# mapping of Terraform state ADDR value to Azure Resource ID value.
name = basename(each.key)
# Mandatory resource attributes
scope = each.value.scope_id
principal_id = each.value.principal_id
# Optional attributes
role_definition_name = try(each.value.role_definition_name, null)
role_definition_id = try(each.value.role_definition_id, null)
# Set explicit dependency on Management Group, Policy, and Role Definition deployments
depends_on = [
time_sleep.after_azurerm_management_group,
time_sleep.after_azurerm_policy_definition,
time_sleep.after_azurerm_policy_set_definition,
time_sleep.after_azurerm_policy_assignment,
time_sleep.after_azurerm_role_definition,
]
}
resource "time_sleep" "after_azurerm_role_assignment" {
depends_on = [
time_sleep.after_azurerm_management_group,
time_sleep.after_azurerm_policy_definition,
time_sleep.after_azurerm_policy_set_definition,
time_sleep.after_azurerm_policy_assignment,
time_sleep.after_azurerm_role_definition,
azurerm_role_assignment.enterprise_scale,
]
triggers = {
"azurerm_policy_assignment_enterprise_scale" = jsonencode(keys(azurerm_role_assignment.enterprise_scale))
"azurerm_policy_assignment_policy_assignment" = jsonencode(keys(azurerm_role_assignment.policy_assignment))
}
create_duration = local.create_duration_delay["after_azurerm_role_assignment"]
destroy_duration = local.destroy_duration_delay["after_azurerm_role_assignment"]
}