forked from Azure/terraform-azurerm-caf-enterprise-scale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resources.management.tf
139 lines (109 loc) · 4.73 KB
/
resources.management.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
resource "azurerm_resource_group" "management" {
for_each = local.azurerm_resource_group_management
provider = azurerm.management
# Mandatory resource attributes
name = each.value.template.name
location = each.value.template.location
tags = each.value.template.tags
}
resource "azurerm_log_analytics_workspace" "management" {
for_each = local.azurerm_log_analytics_workspace_management
provider = azurerm.management
# Mandatory resource attributes
name = each.value.template.name
location = each.value.template.location
resource_group_name = each.value.template.resource_group_name
# Optional resource attributes
sku = each.value.template.sku
retention_in_days = each.value.template.retention_in_days
daily_quota_gb = each.value.template.daily_quota_gb
cmk_for_query_forced = each.value.template.cmk_for_query_forced
internet_ingestion_enabled = each.value.template.internet_ingestion_enabled
internet_query_enabled = each.value.template.internet_query_enabled
reservation_capacity_in_gb_per_day = each.value.template.reservation_capacity_in_gb_per_day
tags = each.value.template.tags
# allow_resource_only_permissions = each.value.template.allow_resource_only_permissions # Available only in v3.36.0 onwards
# Set explicit dependency on Resource Group deployment
depends_on = [
azurerm_resource_group.management,
]
}
resource "azurerm_log_analytics_solution" "management" {
for_each = local.azurerm_log_analytics_solution_management
provider = azurerm.management
# Mandatory resource attributes
solution_name = each.value.template.solution_name
location = each.value.template.location
resource_group_name = each.value.template.resource_group_name
workspace_resource_id = each.value.template.workspace_resource_id
workspace_name = each.value.template.workspace_name
plan {
publisher = each.value.template.plan.publisher
product = each.value.template.plan.product
}
# Optional resource attributes
tags = each.value.template.tags
# Set explicit dependency on Resource Group, Log Analytics
# workspace and Automation Account to fix issue #109.
# Ideally we would limit to specific solutions, but the
# depends_on block only supports static values.
depends_on = [
azurerm_resource_group.management,
azurerm_log_analytics_workspace.management,
azurerm_automation_account.management,
azurerm_log_analytics_linked_service.management,
]
}
resource "azurerm_automation_account" "management" {
for_each = local.azurerm_automation_account_management
provider = azurerm.management
# Mandatory resource attributes
name = each.value.template.name
location = each.value.template.location
resource_group_name = each.value.template.resource_group_name
# Optional resource attributes
sku_name = each.value.template.sku_name
public_network_access_enabled = each.value.template.public_network_access_enabled
local_authentication_enabled = each.value.template.local_authentication_enabled
tags = each.value.template.tags
# Dynamic configuration blocks
dynamic "identity" {
for_each = each.value.template.identity
content {
# Mandatory attributes
type = identity.value.type
# Optional attributes
identity_ids = lookup(identity.value, "identity_ids", null)
}
}
dynamic "encryption" {
for_each = each.value.template.encryption
content {
# Mandatory attributes
key_vault_key_id = encryption.value["key_vault_key_id"]
# Optional attributes
user_assigned_identity_id = lookup(encryption.value, "user_assigned_identity_id", null)
key_source = lookup(encryption.value, "key_source", null)
}
}
# Set explicit dependency on Resource Group deployment
depends_on = [
azurerm_resource_group.management,
]
}
resource "azurerm_log_analytics_linked_service" "management" {
for_each = local.azurerm_log_analytics_linked_service_management
provider = azurerm.management
# Mandatory resource attributes
resource_group_name = each.value.template.resource_group_name
workspace_id = each.value.template.workspace_id
# Optional resource attributes
read_access_id = each.value.template.read_access_id
write_access_id = each.value.template.write_access_id
# Set explicit dependency on Resource Group, Log Analytics workspace and Automation Account deployments
depends_on = [
azurerm_resource_group.management,
azurerm_log_analytics_workspace.management,
azurerm_automation_account.management,
]
}