forked from claranet/terraform-azurerm-api-management
-
Notifications
You must be signed in to change notification settings - Fork 0
/
r-api-management.tf
160 lines (139 loc) · 6.08 KB
/
r-api-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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
resource "azurerm_api_management" "apim" {
name = coalesce(var.custom_name, local.default_name)
location = var.location
resource_group_name = var.resource_group_name
publisher_name = var.publisher_name
publisher_email = var.publisher_email
sku_name = var.sku_name
dynamic "additional_location" {
for_each = var.additional_location
content {
location = lookup(additional_location.value, "location", null)
dynamic "virtual_network_configuration" {
for_each = lookup(additional_location.value, "subnet_id", null) == null ? [] : [1]
content {
subnet_id = additional_location.value.subnet_id
}
}
}
}
dynamic "certificate" {
for_each = var.certificate_configuration
content {
encoded_certificate = lookup(certificate.value, "encoded_certificate")
certificate_password = lookup(certificate.value, "certificate_password")
store_name = lookup(certificate.value, "store_name")
}
}
identity {
type = var.identity_type
identity_ids = replace(var.identity_type, "UserAssigned", "") == var.identity_type ? null : var.identity_ids
}
dynamic "hostname_configuration" {
for_each = length(concat(
var.management_hostname_configuration,
var.portal_hostname_configuration,
var.developer_portal_hostname_configuration,
var.proxy_hostname_configuration,
)) == 0 ? [] : ["fake"]
content {
dynamic "management" {
for_each = var.management_hostname_configuration
content {
host_name = lookup(management.value, "host_name")
key_vault_id = lookup(management.value, "key_vault_id", null)
certificate = lookup(management.value, "certificate", null)
certificate_password = lookup(management.value, "certificate_password", null)
negotiate_client_certificate = lookup(management.value, "negotiate_client_certificate", false)
}
}
dynamic "portal" {
for_each = var.portal_hostname_configuration
content {
host_name = lookup(portal.value, "host_name")
key_vault_id = lookup(portal.value, "key_vault_id", null)
certificate = lookup(portal.value, "certificate", null)
certificate_password = lookup(portal.value, "certificate_password", null)
negotiate_client_certificate = lookup(portal.value, "negotiate_client_certificate", false)
}
}
dynamic "developer_portal" {
for_each = var.developer_portal_hostname_configuration
content {
host_name = lookup(developer_portal.value, "host_name")
key_vault_id = lookup(developer_portal.value, "key_vault_id", null)
certificate = lookup(developer_portal.value, "certificate", null)
certificate_password = lookup(developer_portal.value, "certificate_password", null)
negotiate_client_certificate = lookup(developer_portal.value, "negotiate_client_certificate", false)
}
}
dynamic "proxy" {
for_each = var.proxy_hostname_configuration
content {
host_name = lookup(proxy.value, "host_name")
default_ssl_binding = lookup(proxy.value, "default_ssl_binding", false)
key_vault_id = lookup(proxy.value, "key_vault_id", null)
certificate = lookup(proxy.value, "certificate", null)
certificate_password = lookup(proxy.value, "certificate_password", null)
negotiate_client_certificate = lookup(proxy.value, "negotiate_client_certificate", false)
}
}
dynamic "scm" {
for_each = var.scm_hostname_configuration
content {
host_name = lookup(scm.value, "host_name")
key_vault_id = lookup(scm.value, "key_vault_id", null)
certificate = lookup(scm.value, "certificate", null)
certificate_password = lookup(scm.value, "certificate_password", null)
negotiate_client_certificate = lookup(scm.value, "negotiate_client_certificate", false)
}
}
}
}
notification_sender_email = var.notification_sender_email
dynamic "policy" {
for_each = var.policy_configuration
content {
xml_content = lookup(policy.value, "xml_content", null)
xml_link = lookup(policy.value, "xml_link", null)
}
}
protocols {
enable_http2 = var.enable_http2
}
dynamic "security" {
for_each = var.security_configuration
content {
enable_backend_ssl30 = lookup(security.value, "enable_backend_ssl30", false)
enable_backend_tls10 = lookup(security.value, "enable_backend_tls10", false)
enable_backend_tls11 = lookup(security.value, "enable_backend_tls11", false)
enable_frontend_ssl30 = lookup(security.value, "enable_frontend_ssl30", false)
enable_frontend_tls10 = lookup(security.value, "enable_frontend_tls10", false)
enable_frontend_tls11 = lookup(security.value, "enable_frontend_tls11", false)
enable_triple_des_ciphers = lookup(security.value, "enable_triple_des_ciphers", false)
}
}
sign_in {
enabled = var.enable_sign_in
}
sign_up {
enabled = var.enable_sign_up
dynamic "terms_of_service" {
for_each = var.terms_of_service_configuration
content {
consent_required = lookup(terms_of_service.value, "consent_required")
enabled = lookup(terms_of_service.value, "enabled")
text = lookup(terms_of_service.value, "text")
}
}
}
virtual_network_type = var.virtual_network_type
dynamic "virtual_network_configuration" {
for_each = toset(var.virtual_network_configuration)
content {
subnet_id = virtual_network_configuration.value
}
}
tags = merge(local.default_tags, var.extra_tags)
depends_on = [azurerm_network_security_rule.management_apim]
}