Skip to content

Commit

Permalink
split routes into 2 different files due to Azure/bicep#1410
Browse files Browse the repository at this point in the history
  • Loading branch information
lukecookssw committed May 9, 2022
1 parent 397a8f3 commit 99cc7d8
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
8 changes: 2 additions & 6 deletions .azure/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,21 @@ module redirect_ruleset './ruleset.bicep' = {


// --- ROUTES ---
module static_site_routes './routes.bicep' = {
module static_site_routes './routes-without-ruleset.bicep' = {
name: 'static-site-routes'
params: {
frontdoor_name: frontdoor_name
origin_group_id: static_site_origin_group.outputs.origin_group_id
endpoint_name: frontdoor_endpoint_name
origin_path: '/*'
// ruleset_id: redirect_ruleset.outputs.out_ruleset_id
route_name: 'gatsby-routes'
accepted_routes: [
'/*'
]
}
dependsOn: [
redirect_ruleset
]
}

module legacy_site_routes './routes.bicep' = {
module legacy_site_routes './routes-with-ruleset.bicep' = {
name: 'legacy-site-routes'
params: {
frontdoor_name: frontdoor_name
Expand Down
4 changes: 2 additions & 2 deletions .azure/routes.bicep → .azure/routes-with-ruleset.bicep
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
param frontdoor_name string
param endpoint_name string
param origin_group_id string
param ruleset_id string = ''
param ruleset_id string
param origin_path string
param route_name string
param accepted_routes array
Expand All @@ -16,7 +16,7 @@ resource endpoint 'Microsoft.Cdn/profiles/afdendpoints@2021-06-01' existing = {
name: endpoint_name
}

resource routes_with_ruleset 'Microsoft.Cdn/profiles/afdendpoints/routes@2021-06-01' = if(!empty(ruleset_id)) {
resource routes_with_ruleset 'Microsoft.Cdn/profiles/afdendpoints/routes@2021-06-01' = {
parent: endpoint
name: route_name
properties: {
Expand Down
38 changes: 38 additions & 0 deletions .azure/routes-without-ruleset.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
param frontdoor_name string
param endpoint_name string
param origin_group_id string
param origin_path string
param route_name string
param accepted_routes array


resource parent 'Microsoft.Cdn/profiles@2021-06-01' existing = {
name: frontdoor_name
}

resource endpoint 'Microsoft.Cdn/profiles/afdendpoints@2021-06-01' existing = {
parent: parent
name: endpoint_name
}

resource routes 'Microsoft.Cdn/profiles/afdendpoints/routes@2021-06-01' = {
parent: endpoint
name: route_name
properties: {
customDomains: []
originGroup: {
id: origin_group_id
}
originPath: origin_path
supportedProtocols: [
'Http'
'Https'
]
patternsToMatch: accepted_routes
forwardingProtocol: 'MatchRequest'
linkToDefaultDomain: 'Enabled'
httpsRedirect: 'Enabled'
enabledState: 'Enabled'
}
}

0 comments on commit 99cc7d8

Please sign in to comment.