-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration_values.tf
90 lines (73 loc) · 2.91 KB
/
configuration_values.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
resource "azurerm_role_assignment" "main" {
for_each = { for x in distinct(local.deployable_apps[*].app_config_name) : x => x if x != null }
scope = azurerm_app_configuration.main[each.key].id
role_definition_name = "App Configuration Data Owner"
principal_id = data.azurerm_client_config.current.object_id
}
resource "azurerm_app_configuration_key" "user-defined" {
for_each = { for app_config in local.app_configs : app_config.key => app_config }
configuration_store_id = azurerm_app_configuration.main[each.value.app_config_name].id
key = each.value.key
value = each.value.value
depends_on = [
azurerm_role_assignment.main,
]
}
resource "azurerm_app_configuration_key" "mongo" {
configuration_store_id = azurerm_app_configuration.main.id
key = "ConnectionStrings:Mongo"
value = local.mongo_db_connection_string
depends_on = [
azurerm_role_assignment.main,
mongodbatlas_advanced_cluster.main
]
}
resource "azurerm_app_configuration_key" "redis" {
configuration_store_id = azurerm_app_configuration.main.id
key = "ConnectionStrings:Redis"
value = local.redis_connection_string
depends_on = [
azurerm_role_assignment.main,
azurerm_redis_cache.main
]
}
resource "azurerm_app_configuration_key" "servicebus" {
configuration_store_id = azurerm_app_configuration.main.id
key = "ConnectionStrings:ServiceBus"
value = azurerm_servicebus_namespace.main.default_primary_connection_string
depends_on = [
azurerm_role_assignment.main,
azurerm_servicebus_namespace.main
]
}
resource "azurerm_app_configuration_key" "key-vault" {
configuration_store_id = azurerm_app_configuration.main.id
key = "KeyVault:Url"
value = azurerm_key_vault.main.vault_uri
depends_on = [
azurerm_role_assignment.main,
azurerm_key_vault.main
]
}
data "azurerm_function_app_host_keys" "js-func-host-keys" {
name = azurerm_windows_function_app.main["abc-func"].name
resource_group_name = azurerm_resource_group.abc.name
}
resource "azurerm_app_configuration_key" "access-key" {
configuration_store_id = azurerm_app_configuration.main.id
key = "JsFunctions:ApiKey"
value = data.azurerm_function_app_host_keys.js-func-host-keys.primary_key
depends_on = [
azurerm_role_assignment.main,
azurerm_windows_function_app.main["abc-func"],
]
}
resource "azurerm_app_configuration_key" "js-api" {
configuration_store_id = azurerm_app_configuration.main.id
key = "JsFunctions:BaseUrl"
value = "https://${azurerm_windows_function_app.main["abc-func"].default_hostname}"
depends_on = [
azurerm_role_assignment.main,
azurerm_windows_function_app.main["abc-func"],
]
}