-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfront_door.tf
69 lines (58 loc) · 2.42 KB
/
front_door.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
# frontdoor
resource "random_id" "front_door_endpoint_name" {
byte_length = 8
}
locals {
front_door_profile_name = "frontdoor-${random_integer.ri.result}"
front_door_endpoint_name = "afd-${lower(random_id.front_door_endpoint_name.hex)}"
front_door_origin_group_name = "MyOriginGroup"
front_door_origin_name = "MyAppServiceOrigin"
front_door_route_name = "MyRoute"
}
resource "azurerm_cdn_frontdoor_profile" "my_front_door" {
name = local.front_door_profile_name
resource_group_name = azurerm_resource_group.rg.name
sku_name = var.front_door_sku_name
}
resource "azurerm_cdn_frontdoor_endpoint" "my_endpoint" {
name = local.front_door_endpoint_name
cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.my_front_door.id
}
resource "azurerm_cdn_frontdoor_origin_group" "my_origin_group" {
name = local.front_door_origin_group_name
cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.my_front_door.id
session_affinity_enabled = true
load_balancing {
sample_size = 4
successful_samples_required = 3
}
health_probe {
path = "/"
request_type = "HEAD"
protocol = "Https"
interval_in_seconds = 100
}
}
resource "azurerm_cdn_frontdoor_origin" "my_app_service_origin" {
name = local.front_door_origin_name
cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.my_origin_group.id
enabled = true
host_name = azurerm_linux_web_app.webapp.default_hostname
http_port = 80
https_port = 443
origin_host_header = azurerm_linux_web_app.webapp.default_hostname
priority = 1
weight = 1000
certificate_name_check_enabled = true
}
resource "azurerm_cdn_frontdoor_route" "my_route" {
name = local.front_door_route_name
cdn_frontdoor_endpoint_id = azurerm_cdn_frontdoor_endpoint.my_endpoint.id
cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.my_origin_group.id
cdn_frontdoor_origin_ids = [azurerm_cdn_frontdoor_origin.my_app_service_origin.id]
supported_protocols = ["Http", "Https"]
patterns_to_match = ["/*"]
forwarding_protocol = "HttpsOnly"
link_to_default_domain = true
https_redirect_enabled = true
}