Skip to content

Commit 87fd32e

Browse files
Refactor diagnostic settings and app logs configuration to conditionally apply based on monitoring enablement
1 parent 40f4c51 commit 87fd32e

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

infra/main.bicep

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -165,18 +165,18 @@ module bastionHost 'br/public:avm/res/network/bastion-host:0.6.1' = if (enablePr
165165
skuName: 'Standard'
166166
location: resourceGroupLocation
167167
virtualNetworkResourceId: virtualNetwork!.outputs.resourceId
168-
diagnosticSettings: [
168+
diagnosticSettings: enableMonitoring ? [
169169
{
170170
name: 'bastionDiagnostics'
171-
workspaceResourceId: enableMonitoring ? logAnalyticsWorkspace!.outputs.resourceId : ''
171+
workspaceResourceId: logAnalyticsWorkspace!.outputs.resourceId
172172
logCategoriesAndGroups: [
173173
{
174174
categoryGroup: 'allLogs'
175175
enabled: true
176176
}
177177
]
178178
}
179-
]
179+
] : null
180180
tags: tags
181181
enableTelemetry: enableTelemetry
182182
publicIPAddressObject: {
@@ -220,10 +220,10 @@ module jumpboxVM 'br/public:avm/res/compute/virtual-machine:0.15.0' = if (enable
220220
subnetResourceId: virtualNetwork!.outputs.jumpboxSubnetResourceId
221221
}
222222
]
223-
diagnosticSettings: [
223+
diagnosticSettings: enableMonitoring ? [
224224
{
225225
name: 'jumpboxDiagnostics'
226-
workspaceResourceId: enableMonitoring ? logAnalyticsWorkspace!.outputs.resourceId : ''
226+
workspaceResourceId: logAnalyticsWorkspace!.outputs.resourceId
227227
logCategoriesAndGroups: [
228228
{
229229
categoryGroup: 'allLogs'
@@ -237,7 +237,7 @@ module jumpboxVM 'br/public:avm/res/compute/virtual-machine:0.15.0' = if (enable
237237
}
238238
]
239239
}
240-
]
240+
] : null
241241
}
242242
]
243243
enableTelemetry: enableTelemetry
@@ -645,13 +645,13 @@ module avmContainerAppEnv 'br/public:avm/res/app/managed-environment:0.11.2' = {
645645
location: resourceGroupLocation
646646
}
647647
managedIdentities: { systemAssigned: true }
648-
appLogsConfiguration: {
648+
appLogsConfiguration: enableMonitoring ? {
649649
destination: 'log-analytics'
650650
logAnalyticsConfiguration: {
651-
customerId: enableMonitoring ? logAnalyticsWorkspace!.outputs.logAnalyticsWorkspaceId : ''
652-
sharedKey: enableMonitoring ? logAnalyticsWorkspace.outputs.primarySharedKey : ''
651+
customerId: logAnalyticsWorkspace!.outputs.logAnalyticsWorkspaceId
652+
sharedKey: logAnalyticsWorkspace.outputs.primarySharedKey
653653
}
654-
}
654+
} : null
655655
workloadProfiles: [
656656
{
657657
name: 'Consumption'
@@ -986,7 +986,7 @@ module avmAppConfig 'br/public:avm/res/app-configuration/configuration-store:0.6
986986
enableTelemetry: enableTelemetry
987987
managedIdentities: { systemAssigned: true }
988988
sku: 'Standard'
989-
diagnosticSettings: [
989+
diagnosticSettings: enableMonitoring ? [
990990
{
991991
workspaceResourceId: enableMonitoring ? logAnalyticsWorkspace!.outputs.resourceId : ''
992992
logCategoriesAndGroups: [
@@ -996,7 +996,7 @@ module avmAppConfig 'br/public:avm/res/app-configuration/configuration-store:0.6
996996
}
997997
]
998998
}
999-
]
999+
] : null
10001000
disableLocalAuth: false
10011001
replicaLocations: (resourceGroupLocation != secondaryLocation) ? [secondaryLocation] : []
10021002
roleAssignments: [

0 commit comments

Comments
 (0)