-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathr-function-flex.tf
More file actions
297 lines (259 loc) · 15.7 KB
/
r-function-flex.tf
File metadata and controls
297 lines (259 loc) · 15.7 KB
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
resource "azurerm_function_app_flex_consumption" "main" {
count = local.is_linux_flex ? 1 : 0
name = local.function_app_name
location = var.location
resource_group_name = var.resource_group_name
service_plan_id = module.service_plan.id
runtime_name = var.runtime_name
runtime_version = var.runtime_version
storage_container_type = "blobContainer"
storage_container_endpoint = "${local.storage_account.primary_blob_endpoint}${one(azurerm_storage_container.flex_container[*].name)}"
storage_authentication_type = var.storage_uses_managed_identity ? (var.storage_user_assigned_identity_id != null ? "UserAssignedIdentity" : "SystemAssignedIdentity") : "StorageAccountConnectionString"
storage_access_key = !var.storage_uses_managed_identity ? local.storage_account.primary_access_key : null
storage_user_assigned_identity_id = var.storage_uses_managed_identity ? var.storage_user_assigned_identity_id : null
maximum_instance_count = var.maximum_instance_count
instance_memory_in_mb = var.instance_memory_mb
virtual_network_subnet_id = var.vnet_integration_subnet_id
public_network_access_enabled = var.public_network_access_enabled
app_settings = local.application_settings
dynamic "site_config" {
for_each = local.site_config[*]
content {
api_definition_url = lookup(site_config.value, "api_definition_url", null)
api_management_api_id = lookup(site_config.value, "api_management_api_id", null)
app_command_line = lookup(site_config.value, "app_command_line", null)
default_documents = lookup(site_config.value, "default_documents", null)
health_check_path = lookup(site_config.value, "health_check_path", null)
health_check_eviction_time_in_min = lookup(site_config.value, "health_check_eviction_time_in_min", null)
http2_enabled = lookup(site_config.value, "http2_enabled", null)
load_balancing_mode = lookup(site_config.value, "load_balancing_mode", null)
managed_pipeline_mode = lookup(site_config.value, "managed_pipeline_mode", null)
minimum_tls_version = lookup(site_config.value, "minimum_tls_version", lookup(site_config.value, "min_tls_version", "1.2"))
remote_debugging_enabled = lookup(site_config.value, "remote_debugging_enabled", false)
remote_debugging_version = lookup(site_config.value, "remote_debugging_version", null)
runtime_scale_monitoring_enabled = lookup(site_config.value, "runtime_scale_monitoring_enabled", null)
use_32_bit_worker = lookup(site_config.value, "use_32_bit_worker", null)
websockets_enabled = lookup(site_config.value, "websockets_enabled", false)
application_insights_connection_string = lookup(site_config.value, "application_insights_connection_string", null)
application_insights_key = lookup(site_config.value, "application_insights_key", false)
worker_count = lookup(site_config.value, "worker_count", null)
vnet_route_all_enabled = lookup(site_config.value, "vnet_route_all_enabled", var.vnet_integration_subnet_id != null)
ip_restriction_default_action = lookup(site_config.value, "ip_restriction_default_action", "Deny")
scm_ip_restriction_default_action = lookup(site_config.value, "scm_ip_restriction_default_action", "Deny")
dynamic "ip_restriction" {
for_each = concat(local.subnets, local.cidrs, local.service_tags)
content {
name = ip_restriction.value.name
ip_address = ip_restriction.value.ip_address
virtual_network_subnet_id = ip_restriction.value.virtual_network_subnet_id
service_tag = ip_restriction.value.service_tag
priority = ip_restriction.value.priority
action = ip_restriction.value.action
dynamic "headers" {
for_each = var.ip_restriction_headers[*]
content {
x_azure_fdid = headers.value.x_azure_fdid
x_fd_health_probe = headers.value.x_fd_health_probe
x_forwarded_for = headers.value.x_forwarded_for
x_forwarded_host = headers.value.x_forwarded_host
}
}
}
}
dynamic "scm_ip_restriction" {
for_each = concat(local.scm_subnets, local.scm_cidrs, local.scm_service_tags)
content {
name = scm_ip_restriction.value.name
ip_address = scm_ip_restriction.value.ip_address
virtual_network_subnet_id = scm_ip_restriction.value.virtual_network_subnet_id
service_tag = scm_ip_restriction.value.service_tag
priority = scm_ip_restriction.value.priority
action = scm_ip_restriction.value.action
dynamic "headers" {
for_each = var.scm_ip_restriction_headers[*]
content {
x_azure_fdid = headers.value.x_azure_fdid
x_fd_health_probe = headers.value.x_fd_health_probe
x_forwarded_for = headers.value.x_forwarded_for
x_forwarded_host = headers.value.x_forwarded_host
}
}
}
}
# scm_type = lookup(site_config.value, "scm_type", null)
scm_use_main_ip_restriction = length(var.scm_allowed_ips) > 0 || var.scm_allowed_subnet_ids != null ? false : true
dynamic "cors" {
for_each = lookup(site_config.value, "cors", null)[*]
content {
allowed_origins = lookup(cors.value, "allowed_origins", [])
support_credentials = lookup(cors.value, "support_credentials", false)
}
}
dynamic "app_service_logs" {
for_each = lookup(site_config.value, "app_service_logs", null)[*]
content {
disk_quota_mb = lookup(app_service_logs.value, "disk_quota_mb", null)
retention_period_days = lookup(app_service_logs.value, "retention_period_days", null)
}
}
}
}
dynamic "sticky_settings" {
for_each = var.sticky_settings[*]
content {
app_setting_names = sticky_settings.value.app_setting_names
connection_string_names = sticky_settings.value.connection_string_names
}
}
https_only = var.https_only
client_certificate_enabled = var.client_certificate_enabled
client_certificate_mode = var.client_certificate_mode
dynamic "auth_settings_v2" {
for_each = lookup(var.auth_settings_v2, "auth_enabled", false) ? var.auth_settings_v2[*] : []
content {
auth_enabled = lookup(auth_settings_v2.value, "auth_enabled", false)
runtime_version = lookup(auth_settings_v2.value, "runtime_version", "~1")
config_file_path = lookup(auth_settings_v2.value, "config_file_path", null)
require_authentication = lookup(auth_settings_v2.value, "require_authentication", null)
unauthenticated_action = lookup(auth_settings_v2.value, "unauthenticated_action", "RedirectToLoginPage")
default_provider = lookup(auth_settings_v2.value, "default_provider", "azureactivedirectory")
excluded_paths = lookup(auth_settings_v2.value, "excluded_paths", null)
require_https = lookup(auth_settings_v2.value, "require_https", true)
http_route_api_prefix = lookup(auth_settings_v2.value, "http_route_api_prefix", "/.auth")
forward_proxy_convention = lookup(auth_settings_v2.value, "forward_proxy_convention", "NoProxy")
forward_proxy_custom_host_header_name = lookup(auth_settings_v2.value, "forward_proxy_custom_host_header_name", null)
forward_proxy_custom_scheme_header_name = lookup(auth_settings_v2.value, "forward_proxy_custom_scheme_header_name", null)
dynamic "apple_v2" {
for_each = lookup(auth_settings_v2.value, "apple_v2", null)[*]
content {
client_id = lookup(apple_v2.value, "client_id", null)
client_secret_setting_name = lookup(apple_v2.value, "client_secret_setting_name", null)
}
}
dynamic "active_directory_v2" {
for_each = lookup(auth_settings_v2.value, "active_directory_v2", null)[*]
content {
client_id = lookup(active_directory_v2.value, "client_id", null)
tenant_auth_endpoint = lookup(active_directory_v2.value, "tenant_auth_endpoint", null)
client_secret_setting_name = lookup(active_directory_v2.value, "client_secret_setting_name", null)
client_secret_certificate_thumbprint = lookup(active_directory_v2.value, "client_secret_certificate_thumbprint", null)
jwt_allowed_groups = lookup(active_directory_v2.value, "jwt_allowed_groups", null)
jwt_allowed_client_applications = lookup(active_directory_v2.value, "jwt_allowed_client_applications", null)
www_authentication_disabled = lookup(active_directory_v2.value, "www_authentication_disabled", false)
allowed_groups = lookup(active_directory_v2.value, "allowed_groups", null)
allowed_identities = lookup(active_directory_v2.value, "allowed_identities", null)
allowed_applications = lookup(active_directory_v2.value, "allowed_applications", null)
login_parameters = lookup(active_directory_v2.value, "login_parameters", null)
allowed_audiences = lookup(active_directory_v2.value, "allowed_audiences", null)
}
}
dynamic "azure_static_web_app_v2" {
for_each = lookup(auth_settings_v2.value, "azure_static_web_app_v2", null)[*]
content {
client_id = lookup(azure_static_web_app_v2.value, "client_id", null)
}
}
dynamic "custom_oidc_v2" {
for_each = lookup(auth_settings_v2.value, "custom_oidc_v2", null)[*]
content {
name = lookup(custom_oidc_v2.value, "name", null)
client_id = lookup(custom_oidc_v2.value, "client_id", null)
openid_configuration_endpoint = lookup(custom_oidc_v2.value, "openid_configuration_endpoint", null)
name_claim_type = lookup(custom_oidc_v2.value, "name_claim_type", null)
scopes = lookup(custom_oidc_v2.value, "scopes", null)
client_credential_method = lookup(custom_oidc_v2.value, "client_credential_method", null)
client_secret_setting_name = lookup(custom_oidc_v2.value, "client_secret_setting_name", null)
authorisation_endpoint = lookup(custom_oidc_v2.value, "authorisation_endpoint", null)
token_endpoint = lookup(custom_oidc_v2.value, "token_endpoint", null)
issuer_endpoint = lookup(custom_oidc_v2.value, "issuer_endpoint", null)
certification_uri = lookup(custom_oidc_v2.value, "certification_uri", null)
}
}
dynamic "facebook_v2" {
for_each = lookup(auth_settings_v2.value, "facebook_v2", null)[*]
content {
app_id = lookup(facebook_v2.value, "app_id", null)
app_secret_setting_name = lookup(facebook_v2.value, "app_secret_setting_name", null)
graph_api_version = lookup(facebook_v2.value, "graph_api_version", null)
login_scopes = lookup(facebook_v2.value, "login_scopes", null)
}
}
dynamic "github_v2" {
for_each = lookup(auth_settings_v2.value, "github_v2", null)[*]
content {
client_id = lookup(github_v2.value, "client_id", null)
client_secret_setting_name = lookup(github_v2.value, "client_secret_setting_name", null)
login_scopes = lookup(github_v2.value, "login_scopes", null)
}
}
dynamic "google_v2" {
for_each = lookup(auth_settings_v2.value, "google_v2", null)[*]
content {
client_id = lookup(google_v2.value, "client_id", null)
client_secret_setting_name = lookup(google_v2.value, "client_secret_setting_name", null)
allowed_audiences = lookup(google_v2.value, "allowed_audiences", null)
login_scopes = lookup(google_v2.value, "login_scopes", null)
}
}
dynamic "microsoft_v2" {
for_each = lookup(auth_settings_v2.value, "microsoft_v2", null)[*]
content {
client_id = lookup(microsoft_v2.value, "client_id", null)
client_secret_setting_name = lookup(microsoft_v2.value, "client_secret_setting_name", null)
allowed_audiences = lookup(microsoft_v2.value, "allowed_audiences", null)
login_scopes = lookup(microsoft_v2.value, "login_scopes", null)
}
}
dynamic "twitter_v2" {
for_each = lookup(auth_settings_v2.value, "twitter_v2", null)[*]
content {
consumer_key = lookup(twitter_v2.value, "consumer_key", null)
consumer_secret_setting_name = lookup(twitter_v2.value, "consumer_secret_setting_name", null)
}
}
login {
logout_endpoint = lookup(local.auth_settings_v2_login, "logout_endpoint", null)
cookie_expiration_convention = lookup(local.auth_settings_v2_login, "cookie_expiration_convention", "FixedTime")
cookie_expiration_time = lookup(local.auth_settings_v2_login, "cookie_expiration_time", "08:00:00")
preserve_url_fragments_for_logins = lookup(local.auth_settings_v2_login, "preserve_url_fragments_for_logins", false)
token_refresh_extension_time = lookup(local.auth_settings_v2_login, "token_refresh_extension_time", 72)
token_store_enabled = lookup(local.auth_settings_v2_login, "token_store_enabled", false)
token_store_path = lookup(local.auth_settings_v2_login, "token_store_path", null)
token_store_sas_setting_name = lookup(local.auth_settings_v2_login, "token_store_sas_setting_name", null)
validate_nonce = lookup(local.auth_settings_v2_login, "validate_nonce", true)
nonce_expiration_time = lookup(local.auth_settings_v2_login, "nonce_expiration_time", "00:05:00")
allowed_external_redirect_urls = lookup(local.auth_settings_v2_login, "allowed_external_redirect_urls", null)
}
}
}
dynamic "always_ready" {
for_each = var.always_ready_functions
content {
name = always_ready.value.name
instance_count = min(always_ready.value.instance_count, var.maximum_instance_count)
}
}
dynamic "identity" {
for_each = var.identity_type[*]
content {
type = identity.value
identity_ids = endswith(identity.value, "UserAssigned") ? var.identity_ids : null
}
}
tags = merge(local.default_tags, var.extra_tags, var.function_app_extra_tags)
lifecycle {
ignore_changes = [
app_settings.WEBSITE_RUN_FROM_ZIP,
app_settings.WEBSITE_RUN_FROM_PACKAGE,
app_settings.MACHINEKEY_DecryptionKey,
app_settings.WEBSITE_CONTENTAZUREFILECONNECTIONSTRING,
app_settings.WEBSITE_CONTENTSHARE,
tags["hidden-link: /app-insights-instrumentation-key"],
tags["hidden-link: /app-insights-resource-id"],
]
}
}
moved {
from = module.flex_function[0].azurerm_function_app_flex_consumption.main
to = azurerm_function_app_flex_consumption.main[0]
}