generated from getindata/terraform-module-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
28 lines (21 loc) · 976 Bytes
/
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
resource "azurerm_management_group" "this" {
count = module.this.enabled ? 1 : 0
name = local.name_from_descriptor
display_name = (var.display_name != null
? var.display_name
: title(replace(module.this.name, "-", " ")))
parent_management_group_id = var.parent_management_group_id
}
resource "azurerm_management_group_policy_assignment" "this" {
for_each = module.this.enabled ? var.management_group_policies : {}
name = each.key
management_group_id = local.management_group_id
policy_definition_id = each.value.policy_definition_id
#If parameters is an empty map, pass null
parameters = length(each.value.parameters) == 0 ? null : jsonencode(each.value.parameters)
}
resource "azurerm_management_group_subscription_association" "this" {
count = module.this.enabled ? length(var.subscription_ids) : 0
management_group_id = local.management_group_id
subscription_id = format("/subscriptions/%s", var.subscription_ids[count.index])
}