Skip to content

Commit

Permalink
Move around refs
Browse files Browse the repository at this point in the history
  • Loading branch information
harryy94 committed Feb 4, 2025
1 parent f77cbc6 commit 49f9e4f
Showing 1 changed file with 57 additions and 17 deletions.
74 changes: 57 additions & 17 deletions src/infrastructure/terraform/frontdoor.tf
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,44 @@ resource "azurerm_cdn_frontdoor_origin_group" "frontdoor-origin-group" {
successful_samples_required = 2
}
}
resource "azurerm_cdn_frontdoor_origin_group" "frontdoor-origin-staging-group" {
cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.frontdoor-web-profile.id
name = "${local.service_prefix}-web-staging-fd-origin-group"

health_probe {
interval_in_seconds = 60
protocol = "Https"
request_type = "GET"
path = "/health"
}

load_balancing {
sample_size = 4
successful_samples_required = 2
}
}

resource "azurerm_cdn_frontdoor_origin" "frontdoor-web-origin" {
cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.frontdoor-origin-group.id
certificate_name_check_enabled = false
host_name = azurerm_linux_web_app.web-app-service.default_hostname
http_port = 80
https_port = 443
origin_host_header = azurerm_linux_web_app.web-app-service.default_hostname
priority = 1
weight = 1
name = "${local.service_prefix}-web-fd-origin"
}

resource "azurerm_cdn_frontdoor_origin" "frontdoor-web-staging-origin" {
cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.frontdoor-origin-group.id
cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.frontdoor-origin-staging-group.id
certificate_name_check_enabled = false
host_name = azurerm_linux_web_app_slot.web-app-service-staging.default_hostname
http_port = 80
https_port = 443
origin_host_header = azurerm_linux_web_app_slot.web-app-service-staging.default_hostname
priority = 1
weight = 1
name = "${local.service_prefix}-web-staging-fd-origin"
}

Expand All @@ -125,27 +151,41 @@ resource "azurerm_cdn_frontdoor_route" "frontdoor-web-route" {
cdn_frontdoor_endpoint_id = azurerm_cdn_frontdoor_endpoint.frontdoor-web-endpoint.id
cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.frontdoor-origin-group.id
cdn_frontdoor_origin_ids = [azurerm_cdn_frontdoor_origin.frontdoor-web-origin.id]
patterns_to_match = ["/*"]
supported_protocols = ["Http", "Https"]

forwarding_protocol = "MatchRequest"
https_redirect_enabled = true
patterns_to_match = ["/*"]
supported_protocols = ["Http", "Https"]
}

resource "azurerm_cdn_frontdoor_route" "frontdoor-staging-web-route" {
name = "${local.service_prefix}-web-staging-fd-route"
cdn_frontdoor_endpoint_id = azurerm_cdn_frontdoor_endpoint.frontdoor-web-endpoint.id
cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.frontdoor-origin-group.id
cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.frontdoor-origin-staging-group.id
cdn_frontdoor_origin_ids = [azurerm_cdn_frontdoor_origin.frontdoor-web-staging-origin.id]
patterns_to_match = ["/staging-health"]
supported_protocols = ["Http", "Https"]

forwarding_protocol = "MatchRequest"
https_redirect_enabled = true
patterns_to_match = ["/staging-health"]
supported_protocols = ["Http", "Https"]

cdn_frontdoor_rule_set_ids = [azurerm_cdn_frontdoor_rule_set.frontdoor-staging-rule-set.id]
}

# routing_rule {
# name = "webStagingRoutingRule"
# accepted_protocols = ["Http", "Https"]
# patterns_to_match = ["/staging-health"]
# frontend_endpoints = ["${local.service_prefix}-web-fd"]
# forwarding_configuration {
# forwarding_protocol = "MatchRequest"
# backend_pool_name = "${local.service_prefix}-webStagingBackend"
# custom_forwarding_path = "/health"
# }
# }
resource "azurerm_cdn_frontdoor_rule_set" "frontdoor-staging-rule-set" {
cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.frontdoor-web-profile.id
name = "${local.service_prefix}-web-staging-rule-set"
}

resource "azurerm_cdn_frontdoor_rule" "frontdoor-staging-rewrite-rule" {
cdn_frontdoor_rule_set_id = azurerm_cdn_frontdoor_rule_set.frontdoor-staging-rule-set.id
name = "${local.service_prefix}-web-staging-rewrite-rule"
order = 0

actions {
url_rewrite_action {
destination = "/health"
source_pattern = "/staging-health"
}
}
}

0 comments on commit 49f9e4f

Please sign in to comment.