forked from aztfmod/terraform-azurerm-caf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
front_doors.tf
79 lines (65 loc) · 4.12 KB
/
front_doors.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
module "front_doors" {
source = "./modules/networking/front_door"
for_each = local.networking.front_doors
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) : 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)].name
location = can(each.value.resource_group.location) || can(each.value.resource_group_location) ? try(each.value.resource_group.location, each.value.resource_group_location) : 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)].location
base_tags = try(local.global_settings.inherit_tags, false) ? try(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)].tags, {}) : {}
client_config = local.client_config
diagnostics = local.combined_diagnostics
front_door_waf_policies = local.combined_objects_front_door_waf_policies
keyvaults = local.combined_objects_keyvaults
global_settings = local.global_settings
keyvault_id = can(each.value.keyvault_id) || can(each.value.keyvault_key) == false ? try(each.value.keyvault_id, null) : local.combined_objects_keyvaults[try(each.value.lz_key, local.client_config.landingzone_key)][each.value.keyvault_key].id
keyvault_certificate_requests = local.combined_objects_keyvault_certificate_requests
settings = each.value
}
output "front_doors" {
value = module.front_doors
}
# Register Azure FrontDoor service in the directory.
#
locals {
front_door_application_id = "ad0e1c7e-6d38-4ba4-9efd-0bc77ba9f037"
}
# Execute the SP creation before from the AZ cli
# It will register the Azure FrontDoor global application ID with a service principal into your azure AD tenant
# "az ad sp create --id ad0e1c7e-6d38-4ba4-9efd-0bc77ba9f037"
data "azuread_service_principal" "front_door" {
for_each = {
for key, value in local.networking.front_doors : key => value
if try(value.keyvault_key, null) != null
}
application_id = local.front_door_application_id
}
module "front_doors_keyvault_access_policy" {
source = "./modules/security/keyvault_access_policies"
for_each = {
for key, value in local.networking.front_doors : key => value
if try(value.keyvault_key, null) != null
}
client_config = local.client_config
keyvault_id = local.combined_objects_keyvaults[try(each.value.lz_key, local.client_config.landingzone_key)][each.value.keyvault_key].id
access_policies = {
front_door_certificate = {
object_id = data.azuread_service_principal.front_door[each.key].object_id
certificate_permissions = ["Get"]
secret_permissions = ["Get"]
}
}
}
module "frontdoor_rules_engine" {
source = "./modules/networking/frontdoor_rules_engine"
for_each = local.networking.frontdoor_rules_engine
global_settings = local.global_settings
client_config = local.client_config
settings = each.value
frontdoor_name = can(each.value.frontdoor.name) ? each.value.frontdoor.name : local.combined_objects_front_door[try(each.value.frontdoor.lz_key, local.client_config.landingzone_key)][each.value.frontdoor.key].name
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) : 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)].name
remote_objects = {
frontdoor = local.combined_objects_front_door
resource_group = local.combined_objects_resource_groups
}
}
output "frontdoor_rules_engine" {
value = module.frontdoor_rules_engine
}