Skip to content

Commit

Permalink
Merge pull request #5 from XPRTZ/feature/shared-infrastructure
Browse files Browse the repository at this point in the history
Moved shared resources from websites to infrastructure
  • Loading branch information
Physer authored Jun 7, 2024
2 parents 5818bcd + dad75fd commit 8edd8b0
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 4 deletions.
27 changes: 23 additions & 4 deletions main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,47 @@ targetScope = 'subscription'
param location string = 'westeurope'

var acrResourceGroupName = 'rg-xprtzbv-acr'
var infrastructureResourceGroupName = 'rg-xprtzbv-infrastructure'

resource acrResourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
resource acrResourceGroup 'Microsoft.Resources/resourceGroups@2024-03-01' = {
name: acrResourceGroupName
location: location
}

resource infrastructureResourceGroup 'Microsoft.Resources/resourceGroups@2024-03-01' = {
name: infrastructureResourceGroupName
location: location
}

module acr 'modules/acr.bicep' = {
scope: acrResourceGroup
name: 'Deploy-Acr'
name: 'deployAcr'
params: {
location: location
}
}

module customRoleDefinitions 'modules/customroledefinitions.bicep' = {
name: 'Deploy-Custom-RoleDefinitions'
name: 'deployCustomRoleDefinitions'
}

module roleAssignments 'modules/roleassignments.bicep' = {
scope: acrResourceGroup
name: 'Deploy-Role-Assignments'
name: 'deployRoleAssignments'
params: {
deploymentsWriterRoleDefinitionId: customRoleDefinitions.outputs.roleDefinitionId
}
}

module analytics 'modules/analytics.bicep' = {
scope: infrastructureResourceGroup
name: 'deployAnalytics'
}

module frontDoorProfile 'modules/frontDoorProfile.bicep' = {
scope: infrastructureResourceGroup
name: 'deployFrontDoorProfile'
params: {
logAnalyticsWorkspaceId: analytics.outputs.logAnalyticsWorkspaceId
}
}
13 changes: 13 additions & 0 deletions modules/analytics.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var logAnalyticsWorkspaceName = 'log-xprtzbv-websites'

resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2023-09-01' = {
name: logAnalyticsWorkspaceName
location: resourceGroup().location
properties: {
sku: {
name: 'PerGB2018'
}
}
}

output logAnalyticsWorkspaceId string = logAnalyticsWorkspace.id
44 changes: 44 additions & 0 deletions modules/frontDoorProfile.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
@allowed([
'Standard_AzureFrontDoor'
'Premium_AzureFrontDoor'
])
param frontDoorSkuName string = 'Standard_AzureFrontDoor'
param logAnalyticsWorkspaceId string

var frontDoorProfileName = 'afd-xprtzbv-websites'

resource frontDoorProfile 'Microsoft.Cdn/profiles@2024-02-01' = {
name: frontDoorProfileName
location: 'global'
sku: {
name: frontDoorSkuName
}
}

resource diagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
name: 'diagnostics-${frontDoorProfileName}'
scope: frontDoorProfile
properties: {
workspaceId: logAnalyticsWorkspaceId
logs: [
{
category: 'FrontDoorAccessLog'
enabled: true
}
{
category: 'FrontDoorHealthProbeLog'
enabled: true
}
{
category: 'FrontDoorWebApplicationFirewallLog'
enabled: true
}
]
metrics: [
{
enabled: true
category: 'AllMetrics'
}
]
}
}

0 comments on commit 8edd8b0

Please sign in to comment.