|
| 1 | +# main.tf |
| 2 | +# Azure Front Door Standard/Premium configuration with required origin group and origin |
| 3 | + |
| 4 | +resource "azurerm_resource_group" "fd" { |
| 5 | + name = var.resource_group_name |
| 6 | + location = var.location |
| 7 | +} |
| 8 | + |
| 9 | +resource "azurerm_cdn_frontdoor_profile" "fd" { |
| 10 | + name = var.front_door_name |
| 11 | + resource_group_name = azurerm_resource_group.fd.name |
| 12 | + sku_name = "Standard_AzureFrontDoor" |
| 13 | +} |
| 14 | + |
| 15 | +resource "azurerm_cdn_frontdoor_endpoint" "fd" { |
| 16 | + name = var.frontend_endpoint_name |
| 17 | + cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.fd.id |
| 18 | +} |
| 19 | + |
| 20 | +resource "azurerm_cdn_frontdoor_origin_group" "fd" { |
| 21 | + name = "originGroup1" |
| 22 | + cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.fd.id |
| 23 | + |
| 24 | + health_probe { |
| 25 | + interval_in_seconds = 30 |
| 26 | + path = var.health_probe_path |
| 27 | + protocol = var.health_probe_protocol |
| 28 | + request_type = "GET" |
| 29 | + } |
| 30 | + |
| 31 | + load_balancing { |
| 32 | + sample_size = 4 |
| 33 | + successful_samples_required = 3 |
| 34 | + } |
| 35 | +} |
| 36 | + |
| 37 | +resource "azurerm_cdn_frontdoor_origin" "fd" { |
| 38 | + name = "origin1" |
| 39 | + cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.fd.id |
| 40 | + host_name = var.backend_host |
| 41 | + http_port = 80 |
| 42 | + https_port = 443 |
| 43 | + enabled = true |
| 44 | + origin_host_header = var.backend_host |
| 45 | + priority = 1 |
| 46 | + weight = 1000 |
| 47 | + certificate_name_check_enabled = true |
| 48 | +} |
| 49 | + |
| 50 | +resource "azurerm_cdn_frontdoor_route" "routing_rule" { |
| 51 | + name = var.routing_rule_name |
| 52 | + cdn_frontdoor_endpoint_id = azurerm_cdn_frontdoor_endpoint.fd.id |
| 53 | + cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.fd.id |
| 54 | + cdn_frontdoor_origin_ids = [azurerm_cdn_frontdoor_origin.fd.id] |
| 55 | + supported_protocols = var.accepted_protocols |
| 56 | + patterns_to_match = var.patterns_to_match |
| 57 | + forwarding_protocol = "MatchRequest" |
| 58 | + enabled = true |
| 59 | + https_redirect_enabled = false |
| 60 | + link_to_default_domain = true |
| 61 | +} |
0 commit comments