Skip to content

Commit

Permalink
feat(terraform): create front door and origin group
Browse files Browse the repository at this point in the history
  • Loading branch information
angela-tran committed Nov 30, 2022
1 parent 8625444 commit 844e2c2
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions terraform/front_door.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
locals {
front_door_origin_group_name = data.azurerm_linux_web_app.main.name
front_door_origin_name = data.azurerm_linux_web_app.main.name
front_door_route_name = data.azurerm_linux_web_app.main.name
}

resource "azurerm_cdn_frontdoor_profile" "main" {
name = "mst-courtesy-cards-${local.env_name}"
resource_group_name = data.azurerm_resource_group.main.name
sku_name = "Standard_AzureFrontDoor"
}

resource "azurerm_cdn_frontdoor_endpoint" "main" {
name = "frontdoor-endpoint-${local.env_name}"
cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.main.id
}

resource "azurerm_cdn_frontdoor_origin_group" "main" {
name = local.front_door_origin_group_name
cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.main.id
session_affinity_enabled = true

load_balancing {}
}

resource "azurerm_cdn_frontdoor_origin" "main" {
name = local.front_door_origin_name
cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.main.id

enabled = true
host_name = data.azurerm_linux_web_app.main.default_hostname
http_port = 80
https_port = 443
origin_host_header = data.azurerm_linux_web_app.main.default_hostname
certificate_name_check_enabled = true
priority = 1
weight = 1000
}

resource "azurerm_cdn_frontdoor_route" "main" {
name = local.front_door_route_name
cdn_frontdoor_endpoint_id = azurerm_cdn_frontdoor_endpoint.main.id
cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.main.id
cdn_frontdoor_origin_ids = [azurerm_cdn_frontdoor_origin.main.id]

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

0 comments on commit 844e2c2

Please sign in to comment.