forked from aztfmod/terraform-azurerm-caf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
event_hubs.tf
154 lines (125 loc) · 6.12 KB
/
event_hubs.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
module "event_hub_namespaces" {
source = "./modules/event_hubs/namespaces"
for_each = var.event_hub_namespaces
global_settings = local.global_settings
settings = each.value
storage_accounts = local.combined_objects_storage_accounts
client_config = local.client_config
base_tags = local.global_settings.inherit_tags
resource_group = local.combined_objects_resource_groups[try(each.value.resource_group.lz_key, local.client_config.landingzone_key)][try(each.value.resource_group_key, each.value.resource_group.key)]
resource_group_name = can(each.value.resource_group.name) || can(each.value.resource_group_name) ? try(each.value.resource_group.name, each.value.resource_group_name) : null
location = try(local.global_settings.regions[each.value.region], null)
}
output "event_hub_namespaces" {
value = module.event_hub_namespaces
}
module "event_hub_namespace_auth_rules" {
source = "./modules/event_hubs/namespaces/auth_rules"
for_each = try(var.event_hub_namespace_auth_rules, {})
client_config = local.client_config
global_settings = local.global_settings
namespace_name = module.event_hub_namespaces[each.value.event_hub_namespace_key].name
settings = each.value
resource_group_name = local.combined_objects_resource_groups[try(each.value.lz_key, local.client_config.landingzone_key)][try(each.value.resource_group_key, each.value.resource_group.key)].name
depends_on = [
module.event_hub_namespaces
]
}
output "event_hub_namespace_auth_rules" {
value = module.event_hub_namespace_auth_rules
}
module "event_hub_namespaces_diagnostics" {
source = "./modules/diagnostics"
for_each = var.event_hub_namespaces
resource_id = module.event_hub_namespaces[each.key].id
resource_location = module.event_hub_namespaces[each.key].location
diagnostics = local.combined_diagnostics
profiles = try(each.value.diagnostic_profiles, {})
}
#
# Event_hub_namespace is one of the three diagnostics destination objects and for that reason requires the
# private endpoint to be done at the root module to prevent circular references
#
module "event_hub_namespaces_private_endpoints" {
depends_on = [module.event_hub_namespaces]
source = "./modules/networking/private_endpoint"
for_each = local.event_hub_namespaces_private_endpoints
resource_id = each.value.id
name = each.value.settings.name
location = each.value.location
resource_group_name = each.value.resource_group_name
subnet_id = each.value.subnet_id
settings = each.value.settings
global_settings = local.global_settings
tags = each.value.tags
base_tags = each.value.base_tags
private_dns = local.combined_objects_private_dns
client_config = local.client_config
}
locals {
event_hub_namespaces_private_endpoints = {
for private_endpoint in
flatten(
[
for eh_ns_key, eh_ns in var.event_hub_namespaces : [
for pe_key, pe in try(eh_ns.private_endpoints, {}) : {
eh_ns_key = eh_ns_key
pe_key = pe_key
id = module.event_hub_namespaces[eh_ns_key].id
settings = pe
location = local.resource_groups[pe.resource_group_key].location
resource_group_name = local.resource_groups[pe.resource_group_key].name
subnet_id = try(pe.vnet_key, null) == null ? null : try(local.combined_objects_networking[local.client_config.landingzone_key][pe.vnet_key].subnets[pe.subnet_key].id, local.combined_objects_networking[pe.lz_key][pe.vnet_key].subnets[pe.subnet_key].id)
tags = module.event_hub_namespaces[eh_ns_key].tags
base_tags = local.global_settings.inherit_tags
}
]
]
) : format("%s-%s", private_endpoint.eh_ns_key, private_endpoint.pe_key) => private_endpoint
}
}
module "event_hubs" {
source = "./modules/event_hubs/hubs"
depends_on = [module.event_hub_namespaces]
for_each = try(var.event_hubs, {})
client_config = local.client_config
global_settings = local.global_settings
settings = each.value
namespace_name = module.event_hub_namespaces[each.value.event_hub_namespace_key].name
storage_account_id = try(module.storage_accounts[each.value.storage_account_key].id, null)
resource_group_name = local.combined_objects_resource_groups[try(each.value.lz_key, local.client_config.landingzone_key)][try(each.value.resource_group_key, each.value.resource_group.key)].name
}
output "event_hubs" {
value = module.event_hubs
}
module "event_hub_auth_rules" {
source = "./modules/event_hubs/hubs/auth_rules"
for_each = try(var.event_hub_auth_rules, {})
client_config = local.client_config
global_settings = local.global_settings
settings = each.value
namespace_name = module.event_hub_namespaces[each.value.event_hub_namespace_key].name
eventhub_name = module.event_hubs[each.value.event_hub_name_key].name
resource_group_name = local.combined_objects_resource_groups[try(each.value.lz_key, local.client_config.landingzone_key)][try(each.value.resource_group_key, each.value.resource_group.key)].name
depends_on = [
module.event_hub_namespaces,
module.event_hubs
]
}
output "event_hub_auth_rules" {
value = module.event_hub_auth_rules
}
module "event_hub_consumer_groups" {
source = "./modules/event_hubs/consumer_groups"
for_each = try(var.event_hub_consumer_groups, {})
client_config = local.client_config
global_settings = local.global_settings
settings = each.value
namespace_name = module.event_hub_namespaces[each.value.event_hub_namespace_key].name
eventhub_name = module.event_hubs[each.value.event_hub_name_key].name
resource_group_name = local.combined_objects_resource_groups[try(each.value.lz_key, local.client_config.landingzone_key)][try(each.value.resource_group_key, each.value.resource_group.key)].name
depends_on = [
module.event_hub_namespaces,
module.event_hubs
]
}